Dec 132010

Here is a shell / Bash script that calculates Pi to 1000 digits:

bc -l <<< 'scale=1000; 4*a(1)'
# which is shorter than the equivalent
echo "scale=1000;4*a(1)" | bc -l

One more calculation using bc: the golden ratio to 10 digits:

bc -l <<< 'scale=10;(1 + sqrt(5))/2'


  • If you want a multi-threaded program (to test the performace of your machine?!) calculating pi, try y-cruncher
VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
calculate pi to a 1000 digits, 10.0 out of 10 based on 1 rating

Related Posts:

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>