Calculating the value of e: Difference between revisions

no edit summary
m (→‎{{header|Raku}}: minor simplification)
No edit summary
Line 3,464:
{{out}}
<pre>e = 2.718281828459046</pre>
 
=={{header|S-BASIC}}==
<syntaxhighlight lang="BASIC">
 
rem - return double-precision value of e
function e = real.double
var fact, n, result, epsilon = real.double
result = 2.0
fact = 1.0
n = 2.0
epsilon = 1.0E-12
repeat
begin
fact = fact / n
n = n + 1.0
result = result + fact
end
until fact < epsilon
end = result
 
rem - test the function
print "Calculated value of e ="; e
print "Value of e as exp(1.0) ="; exp(1.0)
print "Published value of e = 2.718281828459045"
 
end
</syntaxhighlight>
{{out}}
<pre>
Calculated value of e = 2.718281828459
Value of e as exp(1.0) = 2.71828
Published value of e = 2.718281828459045
</pre>
 
=={{header|Scala}}==
{{Out}}Best seen running in your browser either by [https://scalafiddle.io/sf/gLmNcH2/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/WSvNG9xMT5GcugVTvqogVg Scastie (remote JVM)].
Line 3,481 ⟶ 3,515:
println(f"ℯ = ${iter(1L, 2.0, 2, 0)}%.15f")
}</syntaxhighlight>
 
 
=={{header|Scheme}}==
{{trans|JavaScript}}
211

edits