Calculating the value of e: Difference between revisions

(One intermediate revision by one other user not shown)
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,222 ⟶ 4,223:
declare -i e n rfct=one
 
while (( (rfct /= ++n) != 0 ))
do e+=rfct
done
885

edits