Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Big Factorials

Limits 1s, 512 MB

Given an integer N, print the trailing 4 digits of $ N! $ (N factorial).

$ N! = N \times (N-1) \times (N-2) \times ... \times 1 $

Here are some examples of $ N! $ and their last 4 digits.

NN Factorial ($ N! $)Last 4 Digits
366
750405040
11399168006800
1513076743680008000

Input

The input will contain an integer N (0 < N < 1000).

Output

Print the last 4 digits of $ N! $.

Do not print any leading zeroes.

Samples

InputOutput
4
24
InputOutput
10
8800


Discussion
Statistics

83% Solution Ratio

ashik_jiddneyEarliest, 11M ago

edge555Fastest, 0.0s

wasimur_01Lightest, 0 B

saitotaShortest, 36B

Submit

Login to submit