Calculating the value of e: Difference between revisions

PascalABC.NET
(PascalABC.NET)
Line 2,997:
{{out}}
<pre>calc e = 2.718281828459045 intern e= 2.718281828459045</pre>
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
function MyExp(x: real): real;
const eps = 1e-15;
begin
var y := 1.0;
var s := y;
var i := 1;
while y > eps do
begin
y *= x / i;
s += y;
i += 1;
end;
Result := s;
end;
 
begin
Println(MyExp(1));
Println(Exp(1));
end.
</syntaxhighlight>
{{out}}
<pre>
2.71828182845905
2.71828182845905
</pre>
 
 
=={{header|Perl}}==
With the <code>bignum</code> core module in force, Brother's algorithm requires only 18 iterations to match the precision of the built-in value, <code>e</code>.
Line 3,051 ⟶ 3,080:
 
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274</pre>
 
=={{header|Phix}}==
{{trans|Python}}
46

edits