From 7cf16ea48b2f48c1fecd16aeae09f254b616aeda Mon Sep 17 00:00:00 2001 From: Lowl3v3l Date: Wed, 12 Jul 2017 00:42:46 +0200 Subject: [PATCH] typed racket solution for euler 3 --- e0003/euler0003.rkt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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