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
Principles Toward...
Laying My Cards On the...
Poverty is a System,...
On the American...
Some Issues with...

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
September 2008
October 2008
November 2008
December 2008
January 2009
February 2009
March 2009
April 2009
May 2009
June 2009
August 2009
September 2009
October 2009
November 2009
December 2009
January 2010
February 2010
March 2010
April 2010
May 2010
June 2010
July 2010
August 2010
September 2010
January 2011
July 2011
September 2011
January 2012
February 2012

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 science technology web work writing 有感


27610 views
Important Disclaimer