Merge branch 'master' of https://github.com/HackspaceJena/project-euler
This commit is contained in:
commit
ed772e7550
1 changed files with 5 additions and 3 deletions
|
@ -1,10 +1,12 @@
|
||||||
#lang racket
|
#lang typed/racket
|
||||||
|
|
||||||
(require math/number-theory)
|
(require math/number-theory)
|
||||||
|
|
||||||
|
(: max-prime-factor (-> Integer (U False Integer)))
|
||||||
(define (max-prime-factor x)
|
(define (max-prime-factor x)
|
||||||
(if (prime? x) x
|
(if (prime? x) x
|
||||||
(for/or ((i (filter prime? (range 2 (sqrt x)))))
|
(for/or ((i (filter prime? (range 2 (ceiling (assert (sqrt x) real?)))))
|
||||||
(if (zero? (remainder x i)) (max-prime-factor (quotient x i)) #f))))
|
#:when (zero? (remainder x i)))
|
||||||
|
(max-prime-factor (quotient x i)))))
|
||||||
|
|
||||||
(max-prime-factor 600851475143)
|
(max-prime-factor 600851475143)
|
Reference in a new issue