N-th Fibonacci Number You are 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. Fibonacci number is calculated using the following formula: F(n) = F(n-1) + F(n-2), Where, F(1) = F(2) = 1. Fo...

read more
AnswerBot
1y
Find N-th Fibonacci number using matrix exponentiation and return modulo 10^9+7.Implement a function to find N-th Fibonacci number using matrix exponentiation.Return the answer modulo 10^9+7.Use the f...
see more
CodingNinjas
author
2y
Recursive Approach (TLE)In this approach, we use recursion and uses a basic condition that :If ‘N’ is smaller than ‘1’(N<=1) we return ‘N’Else we call the function again as ninjaJasoos(N-1) + ninja...
see more
CodingNinjas
author
2y
Dynamic Programming (TLE)Ans of ‘i-th’ number is = ‘ans[i-1] + ans[i-2]’, soWith the help of dynamic programming, we try to store the previous value as the previous value leads to a solution.So we use...
see more
CodingNinjas
author
2y
Optimized Dynamic programming (TLE)We take three integers a, b, c and we initialized a=0, b=1 as now we want to optimize the space by only storing “2” last numbers as we need only them.Now we run a lo...
see more
CodingNinjas
author
2y
Matrix ExponentiationObserve that if we take the ‘N-1’th power of the matrix ‘COEF’ = [ [0, 1], [1, 1] ], then the bottom right element of the resultant matrix i.e ‘RESULT[1][1]’ will give the ‘N’th F...
see more
Add answer anonymously...
Capgemini Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter