TIGblogs TIG | TIGblogs GROUP TIGBLOGS LOGIN SIGNUP
Evan Donovan's Blog
Evan Donovan's Blog
fun with programming, pt. I: interactive pi in ruby

Here's a little program (pi_calc.rb) I adapted today from the devdaily blog to calculate the value of pi using the converging series 4/1 - 4/3 + 4/5 - 4/7 + 4/9 .... The original program wasn't interactive so you had to keep editing the code just to see how much more accurate the calculation got as you went farther into the series. I fixed that. You should be able to run the program on Mac OS X or on any other Unix-y system that has Ruby installed in /usr/bin. Just open the Terminal, go to the directory to which you've downloaded the script (by using cd), and type ./pi_calc.rb If it doesn't work for you, try doing a chmod 755 pi_calc.rb in the directory to which you downloaded the script. Beyond that, I can make no guarantees about the performance of my code. It's the first Ruby script I've ever...

July 20, 2008 | 12:07 PM Comments  0 comments

Tags:
You must be logged in to add tags.


Evan Donovan's Profile


Latest Posts
sick, exhausted, and...
got some rest; added...
the hypomanic edge?
praise God, I found an...
C.S. Lewis and St....

Monthly Archive
July 2007
August 2007
September 2007
October 2007
November 2007
December 2007
January 2008
February 2008
March 2008
April 2008
May 2008
June 2008
July 2008
August 2008

Change Language


Tags Archive
business computer covenant culture dreams education epigrams ethics faith film funny games general gradlife happenstance literature meta meta- music paucartambo personal philosophy politics sip technology web work writing 有感


10523 views
Important Disclaimer