$|--; my ($a, $b, $c, $d, $m, $n) = (0,1,1,0,0,0); while() { if($b && $d && (my $q=int($a/$b))==int($c/$d)) { $a = 10*($a-$b*$q); $c = 10*($c-$d*$q); print $q; } else { $q = $a; $a = $c; $c = $c * (($m % 3) % 2 ? $n * 2 : 1) + $q; $q = $b; $b = $d; $d = $d * (($m++ % 3) % 2 ? $n++ * 2 : 1) + $q; } } # Hit control-C when it stops printing # due to numeric overflow
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: e with continued fractions
by tachyon (Chancellor) on Jul 18, 2004 at 05:05 UTC | |
by jdalbec (Deacon) on Jul 22, 2004 at 03:29 UTC | |
by tachyon (Chancellor) on Jul 22, 2004 at 04:16 UTC | |
|
Re: e with continued fractions
by bageler (Hermit) on Jul 19, 2004 at 20:15 UTC | |
|
Good to about 45 places; spigot algorithm
by tmoertel (Chaplain) on Jul 21, 2004 at 18:02 UTC | |
by jdalbec (Deacon) on Jul 22, 2004 at 03:06 UTC |