Consider the Fibonacci sequence, defined by the following recursion:
Let . Calculate the remainder of divided by .
Note: the answer is a nonnegative integer below .
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.
Let's start with an identitiy: F 3 n = 5 F n 3 + 3 ( − 1 ) n F n .
How can we use it to solve the problem? Let n be some power of 3 . n is clearly odd. Using the identity, we get: F 3 n = 5 F n 3 − 3 F n . So, F 3 n m o d 5 2 1 is uniquely defined by F n m o d 5 2 1 . Indeed, if x n = F 3 n m o d 5 2 1 , one can verify that x 0 = 1 = x 3 (it's easy to calculate x 3 using the identity and a calculator). Hence, x n has a period of 3, and x 5 7 = x 2 = F 9 = 3 4 .
There are probably many ways to prove the identity, here is one sketch: (it is just a straightforward proof. nothing interesting.)
Start with proving that for any n , k the following holds: F m = F k F m + 1 − k + F k − 1 F m − k . It can be done by a trivial induction on k.
Put m = 3 n , k = n and get F 3 n = F n F 2 n + 1 + F n − 1 F 2 n .
In the same manner, derive the following identities:
F 2 n = F n ( F n + 1 + F n − 1 )
F 2 n + 1 = F n 2 + F n + 1 2
Put everything together: F 3 n = F n ( F n 2 + F n + 1 2 ) + F n − 1 F n ( F n + 1 + F n − 1 ) .
If we divide F 3 n by F n , we get: F n 2 + F n + 1 2 + F n − 1 ( F n + 1 + F n − 1 ) .
Do some algebra and show it equals to 2 F n 2 + 3 F n − 1 F n + 1 .
Now, prove by induction that F n + 1 F n − 1 = F n 2 + ( − 1 ) n , and you're done.