http://www.perlmonks.org?node_id=58445

I always love implementing this (++ if you can tell where the algorithm comes from!)
for($|++,$_++,$a++;;$,+=$a/$_,$_++,$a*=-1,$_++){printf"%.16f\n",$,*4}
This version will run (incessantly) as a one-liner as well. -zeno

Update: As MrNobo1024 has answered correctly, this algorithm was discovered by Gregory and Leibniz.