Last Factorial Digit
Time limit1sMemory limit1024 MB
Given up to 10 values of N (N at most 10), print the last decimal digit of N! for each.
- Level
Easy1 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
The factorial of , written as , is the product of all integers from 1 to . For example, .
This number can get very large, so instead of computing the full product, compute only the last digit of when it is written in base 10.
Input
The first line contains a positive integer (), the number of test cases. Each of the next lines contains a single positive integer . is at most 10.
Output
For each value of , print the last digit of .