Jump to Table of Contents Pop Out Sidebar

Problem 16

More details about this document
Create Date:
Publish Date:
Update Date:
2023-11-06 21:19
Creator:
Emacs 29.2 (Org mode 9.6.15)
License:
This work is licensed under CC BY-SA 4.0

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