Dsa
Math
Hard
Fibonacci GCD
For a given integer N, calculate the N-th Fibonacci number and then determine its greatest common divisor (GCD) with another number M provided in the input.
Input Format:
The first line contains the integer N (0 <= N <= 30). The second line contains the integer M (1 <= M <= 100).
Output Format:
Print the GCD of the N-th Fibonacci number and M.
Example:
Input:
6
12
Output:
6
Key concepts
mathgcdfibonacci
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now