Bernoulli numbers: Difference between revisions

Added Delphi example
m (use wiki markup for links)
(Added Delphi example)
Line 1,122:
}</lang>
The output is exactly the same as the Python entry.
 
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| Velthuis.BigRationals}}
{{Trans|Go}}
Thanks Rudy Velthuis for the [https://github.com/rvelthuis/DelphiBigNumbers Velthuis.BigRationals] library.<br>
 
<lang Delphi>
program Bernoulli_numbers;
 
{$APPTYPE CONSOLE}
 
uses
System.SysUtils,
Velthuis.BigRationals;
 
function b(n: Integer): BigRational;
begin
var a: TArray<BigRational>;
SetLength(a, n + 1);
for var m := 0 to High(a) do
begin
a[m] := BigRational.Create(1, m + 1);
for var j := m downto 1 do
begin
a[j - 1] := (a[j - 1] - a[j]) * j;
end;
end;
Result := a[0];
end;
 
begin
for var n := 0 to 60 do
begin
var bb := b(n);
if bb.Numerator.BitLength > 0 then
writeln(format('B(%2d) =%45s/%s', [n, bb.Numerator.ToString, bb.Denominator.ToString]));
end;
readln;
end.</lang>
 
=={{header|EchoLisp}}==
478

edits