Under construction

Still being built. Things may change

Last Non-Zero Factorial Digit 2

Time limit1sMemory limit128 MB

Summary
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!.

Examples1

  1. Example 1

    Input
    5
    Expected output
    2