Problem 9 » 履歴 » バージョン 1
Noppi, 2023/12/27 01:53
1 | 1 | Noppi | [ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] |
---|---|---|---|
2 | # [[Problem 9]] |
||
3 | |||
4 | ```scheme |
||
5 | #!r6rs |
||
6 | #!chezscheme |
||
7 | |||
8 | (import (chezscheme)) |
||
9 | |||
10 | (define answer-9 |
||
11 | (let loop1 ((a 1)) |
||
12 | (if (< 333 a) |
||
13 | (error "answer-9" "answer-9 was not found!") |
||
14 | (let loop2 ((b a)) |
||
15 | (if (< 499 b) |
||
16 | (loop1 (add1 a)) |
||
17 | (let ((c (- 1000 a b))) |
||
18 | (if (= (+ (expt a 2) (expt b 2)) (expt c 2)) |
||
19 | (* a b c) |
||
20 | (loop2 (add1 b))))))))) |
||
21 | |||
22 | (printf "9: ~D~%" answer-9) |
||
23 | ``` |