CS209 lab10


http://www.maths.nuigalway.ie/~gettrick/teach/cs209/l10.html




Suppose we define the Fibolucci numbers to be:

  1. f0=0
  2. f1=1
  3. f2=2
  4. fn=2fn-1 + fn-2 + fn-3 for all n greater than 2.
So... the first few numbers in this sequence are 0, 1, 2, 5, 13, 33, 84, etc.
Write a program in C that uses the binary powering method (and recursion) to calculate the nth. Fibolucci number. Your program can have the same structure as used in lab 9, but here, we are dealing with a 3x3 matrix and its powers. (The matrix in question is
 
2 1 1
1 0 0
0 1 0
 
)
© NUI, Galway