HOME SUMMARY

Problem 16

1. Problem

Power digit sum

215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.

What is the sum of the digits of the number 21000?

幂的数字和

215 = 32768,而 32768 的各位数字之和是 3 + 2 + 7 + 6 + 8 = 26。

21000 的各位数字之和是多少?

2. Solution

对支持大数运算的语言来说,这不是什么问题:

(- (cl-reduce (lambda (s a) (+ s a -48)) (number-to-string (expt 2 1000))) 48)
;; 1366