CS209 lab8


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




Consider the C program covered in lectures, that calculates the nth Fibonacci number in logarithmic time using binary powering: http://www.maths.nuigalway.ie/~gettrick/teach/cs209/progs/binFIB.c. Instead of using the (global) 2x2 matrix array, one can represent the matrix array (and any of its powers array2, array4, array8, array16, etc.) by just storing 2 numbers, a and b, where the matrix will always have the form (first row: [a+b,b] second row:[b,a] ). Modify the program to use this fact.


© NUI, Galway