Hi people, my first perlmonks post, and my first attempt at a piece
of obfuscated code. Be gentle.
This calculates pi .... slowly. It's actually an approximation
that becomes more accurate over time. I'm not a mathematician - can
you tell? :-) I can't remember where I read this algorithm,
but it rapidly becomes rather slow to get new digits out - very brute
force.
perl -e '$a=$b=1;while(){$b=$b-1/($a+=2)+1/($a+=2);print$b*4 ."\n"unless$a%566661}'
perls handling of floating point numbers probably introduces errors
fairly quickly. My computer is not fast enough to get an accurate
enough pi to test this :-)
Would welcome any comments - a more efficient (in terms of bytes of
code) way of printing out every X'th approximation of pi would be
good - I don't think much of how it is now.