Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Bernoulli-numbers/Seed7/bernoulli-numbers.seed7
Normal file
34
Task/Bernoulli-numbers/Seed7/bernoulli-numbers.seed7
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "bigrat.s7i";
|
||||
|
||||
const func bigRational: bernoulli (in integer: n) is func
|
||||
result
|
||||
var bigRational: bernoulli is bigRational.value;
|
||||
local
|
||||
var integer: m is 0;
|
||||
var integer: j is 0;
|
||||
var array bigRational: a is 0 times bigRational.value;
|
||||
begin
|
||||
a := [0 .. n] times bigRational.value;
|
||||
for m range 0 to n do
|
||||
a[m] := 1_ / bigInteger(succ(m));
|
||||
for j range m downto 1 do
|
||||
a[pred(j)] := bigRational(j) * (a[j] - a[pred(j)]);
|
||||
end for;
|
||||
end for;
|
||||
bernoulli := a[0];
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var bigRational: bernoulli is bigRational.value;
|
||||
var integer: i is 0;
|
||||
begin
|
||||
for i range 0 to 60 do
|
||||
bernoulli := bernoulli(i);
|
||||
if bernoulli <> bigRational.value then
|
||||
writeln("B(" <& i lpad 2 <& ") = " <& bernoulli.numerator lpad 44 <&
|
||||
" / " <& bernoulli.denominator rpad 8 <& " " <& bernoulli);
|
||||
end if;
|
||||
end for;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue