#C8112. Sum of Digits of Factorials

    ID: 52059 Type: Default 1000ms 256MiB

Sum of Digits of Factorials

Sum of Digits of Factorials

Given a positive integer \(N\), your task is to compute the sum of the digits of \(i!\) (i factorial) for every integer \(i\) from 1 to \(N\). More formally, you need to calculate:

\(S(i) = \text{sum of digits}(i!)\)

and output the sequence \(S(1), S(2), \ldots, S(N)\) where \(1 \leq i \leq N\). The operations include computing factorial and summing the digits of a number. Use the latex format for any mathematical formula.

Example:

Input: 5
Output: 1 2 6 6 3

Explanation:

  • 1! = 1, sum = 1
  • 2! = 2, sum = 2
  • 3! = 6, sum = 6
  • 4! = 24, sum = 2+4 = 6
  • 5! = 120, sum = 1+2+0 = 3

inputFormat

A single integer N representing the number of terms.

outputFormat

A sequence of N integers where the i-th integer is the sum of the digits of i! (factorial of i), printed in one line separated by spaces.## sample

1
1

</p>