Calculating the value of e: Difference between revisions
→Python: →UNIX Shell: simplify
(→Python: →UNIX Shell: simplify) |
|||
Line 2:
;Task:
Calculate the value of <big>''e''</big>.
(<big>''e''</big> is also known as ''Euler's number'' and ''Napier's constant''.)
Line 3,055:
{{out}}
<pre>e=2.718281828459046</pre>
=={{header|Python}}==
===Imperative===
Line 3,083 ⟶ 3,084:
;Using integer arithmetic only
Easily generate thousands of digits:
<syntaxhighlight lang="python">e =
while
n += 1
rfct //= n
print(f"{e}\n...in {n} steps")</syntaxhighlight>
{{out}}
Line 4,015 ⟶ 4,016:
=={{header|UNIX Shell}}==
<syntaxhighlight lang="sh"># POSIX requires "signed long" for shell arithmetic, so assume to have at
#
one=1000000000
e=
while [ $
do
e=$((
done
echo "$((e / one + 1)).$((e % one))"</syntaxhighlight>
{{out}}
<pre>2.
=={{header|VBScript}}==
|