Calculating the value of e: Difference between revisions
→AWK: simplify
(→bc: add) |
(→AWK: simplify) |
||
Line 412:
{{out}}
<pre>The value of e = 2.71828182845905</pre>
=={{header|AWK}}==
<syntaxhighlight lang="awk">BEGIN {
for (e = n = rfact = 1; rfact >= 1e-15; rfact /= ++n)
}</syntaxhighlight>▼
▲ e += 1.0 / fact
▲</syntaxhighlight>
{{out}}
<pre>e = 2.718281828459046</pre>▼
▲e=2.718281828459046
=={{header|BASIC}}==
==={{header|BASIC256}}===
Line 557 ⟶ 545:
=={{header|bc}}==
<syntaxhighlight lang="bc">scale = 64
for (e = n =
e</syntaxhighlight>
{{out}}
Line 4,030 ⟶ 4,018:
e=0 n=0 rfct=$one
while [ $((rfct /= (n += 1))) -ne 0 ]
do
e=$((e + rfct))
|