Bernoulli numbers are used in some series expansions of several functions   (trigonometric, hyperbolic, gamma, etc.),   and are extremely important in number theory and analysis.

Note that there are two definitions of Bernoulli numbers;   this task will be using the modern usage   (as per   The National Institute of Standards and Technology convention).

The   nth   Bernoulli number is expressed as   Bn.



Task
   show the Bernoulli numbers   B0   through   B60.
   suppress the output of values which are equal to zero.   (Other than   B1 , all   odd   Bernoulli numbers have a value of zero.)
   express the Bernoulli numbers as fractions  (most are improper fractions).
   the fractions should be reduced.
   index each number in some way so that it can be discerned which Bernoulli number is being displayed.
   align the solidi   (/)   if used  (extra credit).


An algorithm
The Akiyama–Tanigawa algorithm for the "second Bernoulli numbers" as taken from wikipedia is as follows:

 for m from 0 by 1 to n do
    A[m] ← 1/(m+1)
    for j from m by -1 to 1 do
      A[j-1] ← j×(A[j-1] - A[j])
  return A[0] (which is Bn)

See also
 Sequence A027641 Numerator of Bernoulli number B_n on The On-Line Encyclopedia of Integer Sequences.
 Sequence A027642 Denominator of Bernoulli number B_n on The On-Line Encyclopedia of Integer Sequences.
 Entry Bernoulli number on The Eric Weisstein's World of Mathematics (TM).
 Luschny's The Bernoulli Manifesto for a discussion on    B1   =   -½   versus   +½. 


' version 08-10-2016
' compile with: fbc -s console
' uses gmp
 
#Include Once "gmp.bi"
 
#Define max 60
 
Dim As Long n
Dim As ZString Ptr gmp_str :gmp_str = Allocate(1000) ' 1000 char
Dim Shared As Mpq_ptr tmp, big_j
tmp = Allocate(Len(__mpq_struct)) :Mpq_init(tmp)
big_j = Allocate(Len(__mpq_struct)) :Mpq_init(big_j)
 
Dim Shared As Mpq_ptr a(max), b(max)
For n = 0 To max
  A(n) = Allocate(Len(__mpq_struct)) :Mpq_init(A(n))
  B(n) = Allocate(Len(__mpq_struct)) :Mpq_init(B(n))
Next
 
Function Bernoulli(n As Integer) As Mpq_ptr
 
  Dim As Long m, j
 
  For m = 0 To n
    Mpq_set_ui(A(m), 1, m + 1)
    For j = m To 1 Step - 1
      Mpq_sub(tmp, A(j - 1), A(j))
      Mpq_set_ui(big_j, j, 1)                 'big_j = j
      Mpq_mul(A(j - 1), big_j, tmp)
    Next
  Next
 
  Return A(0)
End Function
 
' ------=< MAIN >=------
 
For n = 0 To max
  Mpq_set(B(n), Bernoulli(n))
  Mpq_get_str(gmp_str, 10, B(n))
  If *gmp_str <> "0" Then
    If *gmp_str = "1" Then *gmp_str = "1/1"
    Print Using "B(##) = "; n;
    Print Space(45 - InStr(*gmp_str, "/")); *gmp_str
  End If
Next
 
 
' empty keyboard buffer
While Inkey <> "" :Wend
Print :Print "hit any key to end program"
Sleep
End