- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion

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

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.

## Algorithm

### fiboDivTen(term)

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

## Example

#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"; }

## Output

Divisible

- Related Articles
- N-th Fibonacci number in Python Program
- Python Program for n-th Fibonacci number
- 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?
- Check if the n-th term is odd or even in a Fibonacci like sequence
- Program to find ex in an efficient way in Python
- Java program to check whether the given number is an Armstrong number
- What is the most efficient way to check the presence of a row in a MySQL table?
- 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?
- Program to find nCr values for r in range 0 to n, in an efficient way in Python
- Justify whether it is true to say that the following are the \( n^{\text {th }} \) terms of an AP.\( 1+n+n^{2} \)
- What is an efficient way to repeat a string to a certain length in Python?