Find the sum of all the Fibonacci numbers F n less than 1 billion which follow the condition 1 3 ∣ ( 4 F n 2 − 2 2 F n + 1 1 )
Details and assumptions :
Fibonacci sequence is defined as F 0 = 0 , F 1 = 1 and for n ≥ 2 , F n = F n − 1 + F n − 2 . Thus, the Fibonacci sequence is 0 , 1 , 1 , 2 , 3 , 5 , 8 , 1 3 , … .
F n denote the n -th Fibonacci number.
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.
So, I don't want to post an official solution since it won't get any upvotes now, which is why I'm posting my solution (which uses a bit of number theory) here in the comments for the sake of variety.
We first reduce the given modular condition as follows:
1 3 ∣ ( 4 F n 2 − 2 2 F n + 1 1 ) ⟺ 4 F n 2 − 2 2 F n + 1 1 ≡ 0 ( m o d 1 3 ) ⟺ 4 F n 2 + 4 F n − 2 ≡ 0 ( m o d 1 3 ) ⟺ 2 F n 2 + 2 F n − 1 ≡ 0 ( m o d 1 3 ) ⟺ 2 F n 2 + 2 F n + 1 2 ≡ 0 ( m o d 1 3 ) ⟺ F n 2 + F n + 6 ≡ 0 ( m o d 1 3 ) ⟺ F n ( F n + 1 ) ≡ − 6 ≡ 7 ( m o d 1 3 )
From the last conclusion, it's easily obtainable that the given condition in the problem is equivalent to F n ≡ { 4 , 8 } ( m o d 1 3 ) by listing out the 1 2 possible modular results for n ( n + 1 ) in Z / 1 3 Z . Hence, we have,
1 3 ∣ ( 4 F n 2 − 2 2 F n + 1 1 ) ⟺ F n ≡ { 4 , 8 } ( m o d 1 3 )
Using the equivalent and simpler modular condition, here 's a C++ solution.
Java code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
Problem Loading...
Note Loading...
Set Loading...
PARI/GP code: