Given two numbers M and N, the task is to check if the M-th and N-th Fibonacci numbers perfectly divide each other or not.
Input: M = 3, N = 6
F(3) = 2, F(6) = 8 and F(6) % F(3) = 0
Input: M = 2, N = 9
A naive approach will be to find the N-th and M-th Fibonacci numbers and check if they are perfectly divisible or not.
An efficient approach is to use the Fibonacci property to determine the result. If m perfectly divides n, then Fm also perfectly divides Fn, else it does not.
Exception: When N is 2, it is always possible as Fibo2 is 1, which divides every other Fibonacci number.
Below is the implementation of the above approach:
Time Complexity: O(1).
- Find two co-prime integers such that the first divides A and the second divides B
- Count of triplets (a, b, c) in the Array such that a divides b and b divides c
- Ratio of mth and nth term in an Arithmetic Progression (AP)
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Sum of P terms of an AP if Mth and Nth terms are given
- Find Pth term of a GP if Mth and Nth terms are given
- Find the Mth element of the Array after K left rotations
- Mth element after K Right Rotations of an Array
- Check if the sum of digits of a number N divides it
- Check if a given number divides the sum of the factorials of its digits
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- G-Fact 18 | Finding nth Fibonacci Number using Golden Ratio
- Nth Even Fibonacci Number
- C/C++ Program for nth multiple of a number in Fibonacci Series
- Program to find last two digits of Nth Fibonacci number
- Find nth Fibonacci number using Golden ratio
- Nth XOR Fibonacci number
- Nth Fibonacci number using Pell's equation
- Program to find Nth odd Fibonacci Number
- Fast Doubling method to find the Nth Fibonacci number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.