操作
Problem 3 » 履歴 » リビジョン 1
リビジョン 1/4
| 次 »
Noppi, 2023/12/27 01:33
Problem 3¶
#!r6rs
#!chezscheme
(import (chezscheme))
(define answer-3
(let* ((n 600851475143)
(check-max (isqrt n)))
(let loop ((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)
Noppi が2023/12/27に更新 · 1件の履歴