Perl one-liner: approximate pi via Monte Carlo method


http://programmingpraxis.com/2009/10/09/calculating-pi/

>perl -e”print 4/(map{$n+=rand()**2+rand()**2<1}1..pop)*$n” 5000
3.1336

59 characters, plus arguments.

Comments (0)