Last Non-Zero Factorial Digit 2
Time limit1sMemory limit128 MB
Compute the last nonzero digit of N! for an N with up to 100 digits, requiring a modular recursive formula rather than direct computation.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Recursion
- Solved
- No attempts yet
Problem
For a natural number N, consider N!. Remove all trailing zeros from its decimal representation, then find the last remaining digit.
Input
The first line contains a natural number N. N has at most 100 decimal digits.
Output
Print the last remaining digit after removing all trailing zeros from N!.