
computer/programs/useless/misc/pi
$|=3,141592;sub _
{print@_}sub o{_++$O[0
];_ 0for 1..$#O}sub O{$;=int
$=/10,'0/^ ^';if($;<9)
{_$_ for @O;;@O=()
;0}push @O,$;;0
,;push@ O,'.'if
$^==1; 0;if($;
==10){ print ,o,@O=(
)}}$?= 1000000 ;$-=10*
(q/@O= digits of pi =10/,1)
*int($? /3)+1;$
_=2for@ ,[0..$-]
,;for$^ (1..$?){
$"=$-;$O =0;until
($"<0){$/= 2*$"+1;$/=
10if$/==1;$==10*$,[$"]+$O;$,
[$"]=$=%$/;$O=int($=/$/
)*$"--,10}O}o
|
This Perl program computes the first million digits of pi
(including the "3" before the decimal point) and prints them.
You can modify the number of digits to be calculated by editing
the "1000000" in the center of the code.
|