Merge remote-tracking branch 'origin/master'

This commit is contained in:
Lowl3v3l 2017-06-13 16:57:32 +02:00
commit 18c802a4c5
2 changed files with 6 additions and 9 deletions

1
1/euler1.py Normal file
View file

@ -0,0 +1 @@
sum([x for x in range(1,1000) if x % 5 == 0 or x % 3 == 0])

View file

@ -2,13 +2,9 @@
(require math/number-theory)
(define (primes x) (filter prime? (range 2 (sqrt x))))
(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))))
(define (primefactors x primes)
(if (prime? x)
(list x)
(if (zero? (remainder x (car primes)))
(cons (car primes) (primefactors (quotient x (car primes)) primes))
(primefactors x (cdr primes)))))
(apply max (primefactors 600851475143 (primes 600851475143)))
(max-prime-factor 600851475143)