Calculating the value of e: Difference between revisions

(3 intermediate revisions by 2 users not shown)
Line 2,106:
[[File:Fōrmulæ - Calculating the value of e 01.png]]
 
[[File:Fōrmulæ - Calculating the value of e 02a02.png]]
 
'''Solution 2.''' Using series
Line 2,112:
[[File:Fōrmulæ - Calculating the value of e 03.png]]
 
[[File:Fōrmulæ - Calculating the value of e 04a04.png]]
 
'''Solution 3.''' Using a program
Line 2,118:
[[File:Fōrmulæ - Calculating the value of e 05.png]]
 
[[File:Fōrmulæ - Calculating the value of e 06a06.png]]
 
=={{header|Go}}==
Line 2,728:
for .fact, .n = 1, 2 ; ; .n += 1 {
val .e0 = .e
.fact x*= .n
.e += 1 / .fact
if abs(.e - .e0) < .epsilon: break
Line 2,744:
e = 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746
</pre>
 
=={{header|Lua}}==
<syntaxhighlight lang="lua">EPSILON = 1.0e-15;
Line 4,219 ⟶ 4,220:
# least 31 bits available, which is sufficient to store (e - 1) * 10^9
 
declare -ir one=100000000010**9
declare -i e n rfct=one
 
while (( (rfct /= ++n) != 0 ))
do e+=rfct
done
885

edits