#C2269. Sum of Digits of Factorial

    ID: 45566 Type: Default 1000ms 256MiB

Sum of Digits of Factorial

Sum of Digits of Factorial

Given a non-negative integer \(N\), compute the sum of the digits of \(N!\) (the factorial of \(N\)). The factorial is defined as \(N! = 1 \times 2 \times \cdots \times N\). For example, \(10! = 3628800\) and the sum of its digits is \(27\). The input consists of several integers, and the processing should stop when the value \(-1\) is encountered (this value should not be processed).

inputFormat

The input is given via STDIN and consists of one integer per line. The input terminates when the integer \(-1\) is read. All numbers before \(-1\) should be processed.

outputFormat

For each integer (except the terminating \(-1\)), output a single line containing the sum of the digits of its factorial.

## sample
10
50
100
-1
27

216 648

</p>