Problem 1 » 履歴 » バージョン 2
Noppi, 2023/12/27 04:43
1 | 1 | Noppi | [ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] |
---|---|---|---|
2 | # [[Problem 1]] |
||
3 | |||
4 | ```scheme |
||
5 | #!r6rs |
||
6 | #!chezscheme |
||
7 | |||
8 | (import (chezscheme)) |
||
9 | |||
10 | (define answer-1 |
||
11 | 2 | Noppi | (let loop ([n 3] [sum 0]) |
12 | 1 | Noppi | (cond |
13 | [(<= 1000 n) sum] |
||
14 | 2 | Noppi | [(or |
15 | (zero? (mod n 3)) |
||
16 | (zero? (mod n 5))) |
||
17 | 1 | Noppi | (loop (add1 n) (+ sum n))] |
18 | [else (loop (add1 n) sum)]))) |
||
19 | |||
20 | (printf "1: ~D~%" answer-1) |
||
21 | ``` |