Calculating the value of e: Difference between revisions
→dc: calculate reciprocal factorial directly, avoiding division by large numbers, ~100 x faster with GNU dc
(→AWK: simplify) |
(→dc: calculate reciprocal factorial directly, avoiding division by large numbers, ~100 x faster with GNU dc) |
||
Line 926:
<syntaxhighlight lang="dc">1000 sn [ n = number of iterations ]sx
2574k [ precision to use during computation ]sx
1 d
[ [ p = begin ]sx
lf li 1 + d si
ln li <p [ if i<n recur ]sx
]sp [ end ]sx
Line 941 ⟶ 940:
2570k [ now reset precision to match correct digits ]sx
n 10P [ and print it out, again with n + 10P ]sx</syntaxhighlight>
▲{{Out}}
<pre>After 1000 iterations, e =
2.7182818284590452353602874713526624977572470936999595749669676277240\
Line 984 ⟶ 982:
574540161372236187893652605381558415871869255386061647798340254351284\
3961294603529133259</pre>
=={{header|Delphi}}==
''See [[#Pascal|Pascal]]''
|