Problem 6 » 履歴 » バージョン 1
Noppi, 2023/12/27 01:40
1 | 1 | Noppi | [ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] |
---|---|---|---|
2 | # [[Problem 6]] |
||
3 | |||
4 | ```scheme |
||
5 | #!r6rs |
||
6 | #!chezscheme |
||
7 | |||
8 | (import (chezscheme)) |
||
9 | |||
10 | (define answer-6 |
||
11 | (let loop ((n 1) (sum-all 0) (squared-all 0)) |
||
12 | (if (< 100 n) |
||
13 | (- (expt sum-all 2) squared-all) |
||
14 | (loop (add1 n) (+ sum-all n) (+ squared-all (expt n 2)))))) |
||
15 | |||
16 | (printf "6: ~D~%" answer-6) |
||
17 | ``` |