fibonacci.frink

Download or view fibonacci.frink in plain text format


/** Function to generate the nth item of the Fibonacci sequence.  It should
    be noted that Fibonacci number 0 is 0 and Fibonacci number 1 is 1.
*/

fibonacciN[n] :=
{
   a = 0
   b = 1
   count = 0
   while count<n
   {
      [a,b] = [b, a + b]
      count = count + 1
   }
   return a
}


Download or view fibonacci.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 20203 days, 11 hours, 6 minutes ago.