Given a number ‘n’, write a function that prints the last two digits of n-th (‘n’ can also be a large number) Fibonacci number.
Input : n = 65 Output : 65 Input : n = 365 Output : 65
Recommended: Please solve it on “PRACTICE” first, before moving on to the solution.
A simple solution is to find n-th Fibonacci number and print its last two digit. But N can be very large, so it wouldn’t work.
A better solution is to use the fact that after 300-th Fibonacci number last two digits starts repeating.
1) Find m = n % 300.
2) Return m-th Fibonacci number.
1 61 13 53
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to find Nth odd Fibonacci Number
- Number of digits in the nth number made of given four digits
- Program to find last two digits of 2^n
- Program to find the last two digits of x^y
- C/C++ Program for nth multiple of a number in Fibonacci Series
- Check if a M-th fibonacci number divides N-th fibonacci number
- Find nth Fibonacci number using Golden ratio
- Fast Doubling method to find the Nth Fibonacci number
- Find the last two missing digits of the given phone number
- Find the last two digits of Factorial of a given Number
- Sum of nth terms of Modified Fibonacci series made by every pair of two arrays
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- Find the Nth element of the modified Fibonacci series
- Find last two digits of sum of N factorials
- G-Fact 18 | Finding nth Fibonacci Number using Golden Ratio
- Nth Even Fibonacci Number
- Nth XOR Fibonacci number
- Nth Fibonacci number using Pell's equation
- Finding number of digits in n'th Fibonacci number
- Find Nth even length palindromic number formed using digits X and Y
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.