note
mdillon
<p>i just used this with <em>N</em>=400 and got a 1638 decimal place <em>e</em>, then with <em>N</em>=500 and got a 2145 decimal place <em>e</em>:</p>
<code>use Math::BigFloat;
$N = shift || 100;
$e = Math::BigFloat->new(1);
$fac = Math::BigFloat->new(1);
for $i (1 .. $N)
{
$fac *= $i;
$e += 1 / $fac;
}
print $e, $/;
</code>
<p>my computer is too slow to wait for it to go any higher. i don't know how far you can take it out.</p>
<p>the number of digits seems to increase with the size of <em>N</em> but i don't know why, nor at what rate this happens.</p>
<p><strong>p.s.</strong> the result of this code looks to me like <em>e</em>, but i have no idea how accurate it is (beyond being basically accurate, i.e. about 2.71828). i compared it to a 10000 digit calculation of <em>e</em> i found on the Net, and it was only the same up to about 40 decimal places. if you're doing this to get an accurate value of <em>e</em> for later use, i would recommend just finding a calculated and verified version of it on the web (or use the version [id://97559|posted] by [IO] in another response to this parent thread, which, as far as i can tell, reliably generates the actual digits of <em>e</em>). if you're just doing this for fun, then have a blast.</p>
97512
97512