124: Last digit of Fibonacci number

Given an integer number (n <= 10^7), return last digit of Fibonacci number

Note: F(0) = 0, F(1) = 1, F(n) = F(n-1) + F(n-2) (n >= 2)

 

Example 1

Input:   501

Output:  6

Example 2

Input:   327553

Output:  3
Difficulty:Easy
Topic:Dynamic programming
Problem #:124