Solution
In this problem, might be so huge that an algorithm looping for iterations will be too slow. Therefore, we need to avoid such a loop. To get an idea of how to solve this problem without going through all Fibonacci numbers for from to , take a look at the table below:
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.