BernoulliNumbers.frink

View or download BernoulliNumbers.frink in plain text format


/** Calculates the Bernoulli numbers.
*/


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

for n=0 to 60
{
   b = BernoulliNumber[n]
   if b != 0
   {
      num = numerator[n]
      den = denominator[n]
   }
}

   


View or download 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 17863 days, 22 hours, 26 minutes ago.