プロジェクト

全般

プロフィール

Problem 9 » 履歴 » リビジョン 2

リビジョン 1 (Noppi, 2023/12/27 01:53) → リビジョン 2/6 (Noppi, 2023/12/27 04:53)

[ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] 
 # [[Problem 9]] 

 ```scheme 
 #!r6rs 
 #!chezscheme 

 (import (chezscheme)) 

 (define answer-9 
   (let loop1 ([a 1]) ((a 1)) 
     (if (< 333 a) 
       (error "answer-9" "answer-9 was not found!") 
       (let loop2 ([b a]) ((b a)) 
         (if (< 499 b) 
           (loop1 (add1 a)) 
           (let ([c ((c (- 1000 a b)]) b))) 
             (if (= (+ (expt a 2) 
                       (expt b 2)) 
                    (expt c 2)) 
               (* a b c) 
               (loop2 (add1 b))))))))) 

 (printf "9: ~D~%" answer-9) 
 ```