/** 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"]]