- Related Questions & Answers
- Python Program for n-th Fibonacci number
- N-th Fibonacci number in Python Program
- Java Program for n-th Fibonacci number
- Write an Efficient Method to Check if a Number is Multiple of 3 in C++
- Check whether a number is a Fibonacci number or not JavaScript
- C/C++ Program for the n-th Fibonacci number?
- Java program to check whether the given number is an Armstrong number
- What is the most efficient way to deep clone an object in JavaScript?
- What is the most efficient way to select a specific number of random rows in MySQL?
- Check whether N is a Dihedral Prime Number or not in Python
- What is the most efficient way to check the presence of a row in a MySQL table?
- n-th number whose sum of digits is ten in C++
- N-th root of a number in C++
- Check whether K-th bit is set or nots in Python
- Java Program for check if a given number is Fibonacci number?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Here we will see one efficient way to check whether the nth Fibonacci term is multiple of 10 or not. Suppose the Fibonacci terms are {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987}. So here 15^{th }(Counting from 0) Fibonacci term is divisible by 10. For 16 it will return true.

One easiest method is generating Fibonacci numbers up to given term, and check whether it is divisible by 10 or not? But this solution is not good, because it will not work for larger terms.

Another good approach is like below −

Fibonacci terms − 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987

These numbers (marked as bold letters) are divisible by 2. And their intervals are 3 Fibonacci terms. Similarly, please check that −

Fibonacci terms: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987

Every 5th term is divisible by 5. Now LCM of 3 and 5 is 15. So we can say that every 15^{th} Fibonacci terms are divisible by 10.

Let us see the algorithm to get the idea.

Begin if term is divisible by 15, then return true end if return false End

#include<iostream> using namespace std; bool fiboDivTen(int term) { if(term % 15 == 0){ return true; } return false; } int main() { int term = 45; if (fiboDivTen(term)) cout << "Divisible"; else cout << "Not Divisible"; }

Divisible

Advertisements