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

12 lines
346 B
Racket
Raw Permalink Normal View History

2017-07-12 00:42:46 +02:00
#lang typed/racket
2017-05-09 19:48:35 +02:00
(require math/number-theory)
2017-07-12 00:42:46 +02:00
(: max-prime-factor (-> Integer (U False Integer)))
2017-06-07 18:04:31 +02:00
(define (max-prime-factor x)
(if (prime? x) x
2017-07-12 00:42:46 +02:00
(for/or ((i (filter prime? (range 2 (ceiling (assert (sqrt x) real?)))))
#:when (zero? (remainder x i)))
(max-prime-factor (quotient x i)))))
2017-05-09 19:48:35 +02:00
2017-06-07 18:04:31 +02:00
(max-prime-factor 600851475143)