![]() |
VOOZH | about |
We know Fibonacci number, Fn = Fn-1 + Fn-2.
First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, .... .
Here are some interesting facts about Fibonacci number :
1. Pattern in Last digits of Fibonacci numbers :
Last digits of first few Fibonacci Numbers are :
0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7, 0, 7, ...
The series of last digits repeats with a cycle length of 60 (Refer this for explanations of this result).
Output:
Sequence is repeating after index 60
Time complexity of the given program is O(max), as it runs two loops from 2 to max-1 and performs constant-time operations inside both loops. Hence, the time complexity is linear in terms of the value of max.
Space complexity of the program is O(max), as it creates an array of size max to store the Fibonacci numbers. The space required for other variables used in the program is constant and negligible compared to the array size. Therefore, the space complexity is also linear in terms of the value of max.
2. Factors of Fibonacci number : On careful observation, we can observe the following thing :
Refer this for details.
Output:
Index of Fibonacci numbers divisible by 2 are :
0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45
48 51 54 57 60 63 66 69 72 75 78 81 84 87
Index of Fibonacci number divisible by 3 are :
0 4 8 12 16 20 24 28 32 36 40 44 48 52
56 60 64 68 72 76 80 84 88
Index of Fibonacci number divisible by 5 are :
0 5 10 15 20 25 30 35 40 45 50
55 60 65 70 75 80 85
Index of Fibonacci number divisible by 8 are :
0 6 12 18 24 30 36 42 48
54 60 66 72 78 84
Time Complexity:
The program uses a single for loop of size MAX, to calculate and store the Fibonacci numbers in the array. Hence, the time complexity for this part of the program is O(MAX). The program then uses another for loop of size MAX, to check each number in the array for divisibility by 2, 3, 5, and 8. The time complexity for this part of the program is also O(MAX). Therefore, the overall time complexity of the program is O(MAX).
Space Complexity:
The program uses an array of size MAX to store the Fibonacci numbers. It also uses four separate arrays of sizes c1, c2, c3, and c4, to store the indexes of the Fibonacci numbers that are divisible by 2, 3, 5, and 8 respectively. The maximum size of these arrays is equal to MAX/3 (when all Fibonacci numbers are divisible by 2). Therefore, the space complexity of the program is O(MAX).
3. Fibonacci number with index number factor : We have some Fibonacci number like F(1) = 1 which is divisible by 1, F(5) = 5 which is divisible by 5, F(12) = 144 which is divisible by 12, F(24) = 46368 which is divisible by 24, F(25) = 75025 which is divisible by 25. This type of index number follow a certain pattern. First, let's keep a look on those index number :
1, 5, 12, 24, 25, 36, 48, 60, 72, 84, 96, 108, 120, 125, 132, .....
On observing it, this series is made up of every number that is multiple of 12 as well as all the number that satisfies the condition of pow(5, k), where k = 0, 1, 2, 3, 4, 5, 6, 7, .......
Output:
Fibonacci numbers divisible by their indexes are :
1 5 12 24 25 36 48 60 72 96
4. Value of f(n-1)*f(n+1) - f(n)*f(n) is (-1)n. Please refer Cassini’s Identity for details.
5. The sum of any ten consecutive Fibonacci numbers is divisible by 11.
Example: 0+1+1+ 2+3+ 5+ 8+13+21+34 =88 which is divisible by 11.
Proof: Just write every term in the sum in terms of F1 and F2, keeping in mind that Fn = Fn-1 + Fn-2.
F1+F2+(F1+F2)+(F1+2F2)+(2F1+3F2)+(3F1+5F2)+(5F1+8F2)+(8F1+13F2)+(13F1+21F2)+(21F1+34F2).
Then the sum is clearly equal to 55F1+88F2=11(5F1+8F2), which is divisible by 11.
Reference :
https://r-knott.surrey.ac.uk/Fibonacci/fibmaths.html