diff --git a/e0003/euler0003.rkt b/e0003/euler0003.rkt index 7f045da..058f0cd 100644 --- a/e0003/euler0003.rkt +++ b/e0003/euler0003.rkt @@ -1,10 +1,12 @@ -#lang 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 (sqrt x))))) - (if (zero? (remainder x i)) (max-prime-factor (quotient x i)) #f)))) + (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) \ No newline at end of file