プロジェクト

全般

プロフィール

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

リビジョン 1 (Noppi, 2023/12/27 01:33) → リビジョン 2/4 (Noppi, 2023/12/27 04:44)

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

 ```scheme 
 #!r6rs 
 #!chezscheme 

 (import (chezscheme)) 

 (define answer-3 
   (let* ([n 600851475143] ((n 600851475143) 
          [check-max (check-max (isqrt n)]) n))) 
     (let loop ([current 3] [rest n] [max-prime 1]) ((current 3) (rest n) (max-prime 1)) 
       (cond 
         [(< check-max current) max-prime] 
         [(zero? (mod rest current)) 
          (loop current (div rest current) current)] 
         [else (loop (+ current 2) rest max-prime)])))) 

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