Problem 6 » 履歴 » バージョン 2
Noppi, 2023/12/27 04:47
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 | 2 | Noppi | (let loop ([n 1] [sum-all 0] [squared-all 0]) |
12 | 1 | Noppi | (if (< 100 n) |
13 | 2 | Noppi | (- (expt sum-all 2) |
14 | squared-all) |
||
15 | (loop (add1 n) (+ sum-all n) (+ squared-all |
||
16 | (expt n 2)))))) |
||
17 | 1 | Noppi | |
18 | (printf "6: ~D~%" answer-6) |
||
19 | ``` |