The source code for bc can be obtained from any GNU site (for example, from; it is very easy to compile and install. An excellent man page and some examples are included with the distribution. The examples include a program to calculate pi to a given number of digits, one to compute prime numbers and one to compute pairs of twin primes.