P is for Practical | |
PerlMonks |
Re: Golf -- compute PIby andreychek (Parson) |
on Apr 16, 2002 at 04:05 UTC ( [id://159407]=note: print w/replies, xml ) | Need Help?? |
Here's a few more methods of achieving pi: # 39 Characters map$x+=(-1)**$_*4/(2*$_+1),0..1e6;die$x Now, I know Ovid said no Trig functions, but I couldn't resist. Perhaps we could consider the next two examples mulligans :-) # 45 Characters use Math::Trig;die 16*atan(1/5)-4*atan(1/239) # 21 Characters use Math::Trig;die pi -Eric Update: Taking some of PrakashK's suggestions, shaved off a few more characters. Thanks PrakashK! :-)
In Section
Meditations
|
|