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

10 lines
256 B
Racket
Raw Normal View History

2017-05-09 19:48:35 +02:00
#lang racket
(require math/number-theory)
2017-06-07 18:04:31 +02:00
(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))))
2017-05-09 19:48:35 +02:00
2017-06-07 18:04:31 +02:00
(max-prime-factor 600851475143)