An example here is a little factorial program.
/*
* Factorial function implemented by recursion.
*/
define fact(n) {
if (n <= 1) return (n);
return (n * fact(n-1));
}
BC can do some other really cool things since it's interpreted and part of Unix is can be called from shells scripts to perform functions.
pi=$(echo "scale=10; 4*a(1)" | bc -l)
From: Krishna K Sent: Tuesday, November 18, 2003 6:56 PM Subject: bc program $ cat x.txt 999999999999999.99 888888888888888.88 777777777777777.77 -66666666666666.66 How can I get the sum of column1( of course there is one column in file) in text file x.txt? and how can I write program to compute sum of column1 on file x.txt? Thanks in advance Krishna
awk '{ print "a = a + " $1 "; a" }' x.txt | bc -l | tail -1
BC - An Arbitrary Precision Desk-Calculator Language PDF Manual
Computation of Bells Numbers using BC
C-BC Mark Hopkins' extended BC language
Some BCMath/PHP number theory programs
Exploring RSA Encryption with BC