Find the sum of the first 35 positive Fibonacci numbers.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Note that the Fibonacci numbers follow the identity k = 1 ∑ n F k = F n + 2 − 1 , which can be proven by a simple induction on n .
Setting n = 3 5 means we need to calculate k = 1 ∑ 3 5 F k = F 3 7 − 1 = 2 4 1 5 7 8 1 7 − 1 = 2 4 1 5 7 8 1 6 (disclosure: I computed F 3 7 by Binet's formula)
Using this method, we can reduce the complexity of computing the sum of the first n Fibonacci numbers down from O ( n ) to O ( lo g n ) by using fast exponentiation (where the floating point errors in Binet's formula can be avoided by using fast exponentiation of matrices over the integers)