Single File Programming Question
Problem Statement
Green Wood High School is set to premiere a programming tournament for high school-aged math and science students across the country. Based on this contest, the school has called for all interested candidates to take a qualifying test at the school premises.
Before the qualifier, the event coordinators chose the problem sets and wanted to code them beforehand to ease the evaluation procedure. They wanted your help to code a few of the problem sets, one of which involved the Fibonacci series.
We all know the Fibonacci sequence, each term of it is the sum of the two previous terms. For Example, F(1) = 1, F(2) = 1, F(3) = 2, and so on.
In this problem, we need to find just the last digit of a Fibonacci series termed F(n), where n is the input.
Write a program using functions to output the last digit of the term F(n).
Example
Input:
13
Output:
3
Explanation:
The Fibonacci series up to the 13th term is 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, and 233.
The last digit of the 13th term, F(13), is 3.
Function Specifications: int fiboLastDigit(int );
Input format :
The input consists of an integer n.
Output format :
The output displays the last digit of the given term F(n).
Code constraints :
1 ≤ n ≤ 50
Sample test cases :
Input 1 :
5
Output 1 :
5
Input 2 :
13
Output 2 :
3
Input 3 :
1
Output 3 :
1