N-th Fibonacci Number Problem Statement
Given an integer ‘N’, your task is to find and return the N’th Fibonacci number using matrix exponentiation.
Since the answer can be very large, return the answer modulo 10^9 + 7.
Formula:
F(n) = F(n-1) + F(n-2),
Where, F(1) = F(2) = 1.
Example:
Input:
N = 5
Output:
5
Input:
The first line contains a single integer ‘T’ denoting the number of test cases to be run. Then the test cases follow. The first line of each test case contains a single integer ‘N’, representing the integer for which we have to find its equivalent Fibonacci number.
Output:
For each test case, print a single integer representing the N’th Fibonacci number. Return the answer modulo 10^9 + 7. Output for each test case will be printed in a separate line.
Constraints:
1 <= T <= 10
1 <= N <= 10^5
- Time Limit: 1 sec.
Note:
You are not required to print anything; it has already been taken care of. Just implement the function.
Follow Up:
Can you solve it in Time Complexity better than O(N)?

AnswerBot
1y
The task is to find the Nth Fibonacci number using matrix exponentiation.
Use matrix exponentiation to efficiently calculate the Nth Fibonacci number
Return the answer modulo 10^9 + 7 to handle large nu...read more
Help your peers!
Add answer anonymously...
Newgen Software Technologies Software Developer interview questions & answers
A Software Developer was asked 12mo agoQ. What are constructors?
A Software Developer was asked 12mo agoQ. Define the concept of OOPs.
A Software Developer was asked Q. What is OOPS in Java?
Popular interview questions of Software Developer
A Software Developer was asked 12mo agoQ1. Define the concept of OOPs.
A Software Developer was asked 12mo agoQ2. What are constructors?
A Software Developer was asked Q3. What is OOPS in Java?
>
Newgen Software Technologies Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

