Algorithm BinaryFib(k): Input: Nonnegative integer k Output: The kth Fibonacci number Fk if k = 0 or 1 then return k else return BinaryFib(k - 1) + BinaryFib(k - 2)
Algorithm LinearFibonacci(k): Input: A nonnegative integer k Output: Pair of Fibonacci numbers (Fk, Fk-1) if k = 1 then return (k, 0) else (i, j) ← LinearFibonacci(k - 1) return (i +j, i)