Single File Programming Question
Problem Statement
Rakshita is studying mathematics and is intrigued by the Fibonacci sequence. She wants to calculate the last digit of a Fibonacci number quickly and efficiently.
She asks for your help to write a program that calculates and returns the last digit of the nth Fibonacci number using a function. The program should use call-by-reference to efficiently return the result.
Example
Input:
13
Output:
4
Explanation:
The Fibonacci series up to the 13th term is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, and 144.
The last digit of the 13th term, F(13), is 4.
Function Specification: fiboLastDigit(int, int& )
Input format :
The input consists of an integer n.
Output format :
The output displays the last digit of the nth Fibonacci number.
Refer to the sample output for formatting specifications.
Code constraints :
The given test cases fall under the following constraints:
1 ≤ n ≤ 50
Sample test cases :
Input 1 :
14
Output 1 :
3
Input 2 :
39
Output 2 :
9
Input 3 :
1
Output 3 :
0
Input 4 :
5
Output 4 :
3