This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
project-euler/e0003/euler0003.rkt
2017-07-12 00:42:46 +02:00

12 lines
No EOL
346 B
Racket

#lang typed/racket
(require math/number-theory)
(: max-prime-factor (-> Integer (U False Integer)))
(define (max-prime-factor x)
(if (prime? x) x
(for/or ((i (filter prime? (range 2 (ceiling (assert (sqrt x) real?)))))
#:when (zero? (remainder x i)))
(max-prime-factor (quotient x i)))))
(max-prime-factor 600851475143)