Timer is Running

The Nth Fibonnaci
Submissions: 3739   Accuracy:

42.67%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Interview Preparation

Given a positive integer N, write a program to find the last digit of the Nth term from the Fibonnaci series and print it.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. 
The first line of each test case contains a positive integer N.

Output:
Print out the last digit of Nth Fibonacci number.

Constraints:
1 <= T <= 100
0 < N <= 1000

Examples: 
Input:
4
1
5
14
300

Output:
1
5
7
0

** For More Input/Output Examples Use 'Expected Output' option **

Author: Rohan Malhotra


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.