Factorial
InterviewTime limit1sMemory limit128 MB
Read n and print the ones digit of n factorial.
- Level
Easy1 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Let be a non-negative integer. The value (read " factorial") is defined as follows. If , then . If , then is the product of all integers from to , that is, . For example, .
Write a program that:
- reads a non-negative integer from standard input,
- computes the units (ones) digit of in its decimal representation,
- prints that result to standard output.
Input
The first and only line of standard input contains a single non-negative integer ().
Output
On the first and only line, print exactly one digit equal to the units digit of in its decimal representation.