n! means n × (n − 1) × … × 3 × 2 × 1
For example, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
阶乘数字和
n! 的意思是 n × (n − 1) × … × 3 × 2 × 1。
例如, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800,所以 10! 的各位数字和是 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27。
求 100! 的各位数字和。
使用 elisp 可以简单完成:
(defun eu20-fac (n)
(pcase n
(0 1)
(a (* (eu20-fac (1- a)) a))))
(- (cl-reduce (lambda (s a) (+ s a -48)) (number-to-string (eu20-fac 100))) 48)
;; 648