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
- Mth bit in Nth binary string from a sequence generated by the given operations
- 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
- Highest power of a number that divides other number
- Count of prime digits of a Number which divides the number
- G-Fact 18 | Finding nth Fibonacci Number using Golden Ratio
- Nth Even Fibonacci Number
- 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
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.