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/3/euler3.rkt
2017-06-07 18:04:31 +02:00

10 lines
No EOL
256 B
Racket

#lang racket
(require math/number-theory)
(define (max-prime-factor x)
(if (prime? x) x
(for/or ((i (filter prime? (range 2 (sqrt x)))))
(if (zero? (remainder x i)) (max-prime-factor (quotient x i)) #f))))
(max-prime-factor 600851475143)