VOOZH about

URL: https://www.geeksforgeeks.org/dsa/efficient-way-check-whether-n-th-fibonacci-number-multiple-10/

⇱ An efficient way to check whether n-th Fibonacci number is multiple of 10 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

An efficient way to check whether n-th Fibonacci number is multiple of 10

Last Updated : 23 Jul, 2025

We are given a variable n, we need to find whether Fibonacci number will be a multiple of 10 or not. 

Examples:

Input : 15
Output : Yes

Input : 17
Output : No


A Simple Method is to find the nth Fibonacci number and check if it is divisible by 10 or not.


Output
Yes

Time complexity: O(n) 
Auxiliary space: O(1)


Efficient Method :
The above solution may not work if n is very large, then it is not possible to find fibonacci number. Moreover, we can check without finding fibonacci number by looking on the pattern. Let's see how !
If number is divisible by 10, then it must have to be divisible by 5 and 2 both. 
Multiples of 2 in Fibonacci Series : 
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 .... 
The number shown in bold are divisible by 2. On careful observation, we finds that every 3rd number is divisible by 2.
Multiples of 5 in Fibonacci Series : 
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 ......
The number shown in bold are divisible by 5. On careful observation, we find that every 5-th number is divisible by 5.
Now LCM of 3 and 5 is 15. So, every 15-th Fibonacci number will be divisible by 10. So, we don't need to find Fibonacci number, just we have to check if n is divisible by 15 or not.

Below is the implementation.


Output
Yes

Time Complexity: O(1) time. 
Auxiliary space: O(1) 


 

Comment
Article Tags: