Problem 6 » 履歴 » リビジョン 3
« 前 |
リビジョン 3/4
(差分)
| 次 »
Noppi, 2023/12/27 13:18
Problem 6¶
Sum Square Difference¶
The sum of the squares of the first ten natural numbers is,
$$1^2 + 2^2 + ... + 10^2 = 385.$$
The square of the sum of the first ten natural numbers is,
$$(1 + 2 + ... + 10)^2 = 55^2 = 3025.$$
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is $3025 - 385 = 2640$.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
二乗和の差¶
最初の10個の自然数について, その二乗の和は,
$$1^2 + 2^2 + ... + 10^2 = 385.$$
最初の10個の自然数について, その和の二乗は,
$$(1 + 2 + ... + 10)^2 = 55^2 = 3025.$$
これらの数の差は 3025 - 385 = 2640 となる.
同様にして, 最初の100個の自然数について二乗の和と和の二乗の差を求めよ.
#!r6rs
#!chezscheme
(import (chezscheme))
(define square-num-list
(map
(lambda (n) (* n n))
(iota 101)))
(define square-sum
(apply + square-num-list))
(define sum-square
(expt (apply + (iota 101))
2))
(define answer-6
(- sum-square square-sum))
(printf "6: ~D~%" answer-6)
Noppi が2023/12/27に更新 · 3件の履歴