You probably already know that N factorial (shown as 'N!') is the product of the integers from 1 through N:
12! = 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 = 479,001,600
The right-most non-zero digit in 12! is 6.
Write a program that reads an integer N (1 ≤ N ≤ 50,000,000) and calculates the rightmost non-zero digit.
Note that 10,000,000! has 2,499,999 zeroes on the end.
A single integer, N
A single line with an integer that is the rightmost non-zero digit of N!.