Download or view BernoulliNumbers.frink in plain text format
/** Calculates the Bernoulli numbers.
Also maybe see:
"A multimodular algorithm for computing Bernoulli numbers":
https://arxiv.org/abs/0807.1347
which is annoying even in its simplest "pseudocode".
*/
BernoulliNumber[n] :=
{
a = new array
for m = 0 to n
{
a@m = 1/(m+1)
for j = m to 1 step -1
a@(j-1) = j * (a@(j-1) - a@j)
}
return a@0
}
/** This is the code for Rosetta Code problem "Bernoulli Numbers":
http://rosettacode.org/wiki/Bernoulli_numbers
*/
/*
result = new array
for n=0 to 60
{
b = BernoulliNumber[n]
if b != 0
{
[num,den] = numeratorDenominator[b]
result.push[[n, num, "/", den]]
}
}
println[formatTable[result, "right"]]
*/
Download or view BernoulliNumbers.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20217 days, 23 hours, 44 minutes ago.