require "bignum" local fmt = require "fmt" local function bernoulli(n) assert(n >= 0, "Argument must be non-negative") local a = table.create(n + 1) for m = 0, n do a[m + 1] = bigrat.recip(m + 1) local j = m while j >= 1 do a[j] = (a[j] - a[j + 1]) * bigrat.int(j) j -= 1 end end return n != 1 ? a[1] : -a[1] --'first' Bernoulli number end local zero = bigrat.int(0) for n = 0, 60 do local b = bernoulli(n) if b != zero then fmt.print("B(%2d) = %44s / %s", n, b:getNum(), b:getDen()) end end