From 5b8cd633e70d453f9f2afdefcf8c6d72d3f85ed2 Mon Sep 17 00:00:00 2001 From: Lowl3v3l Date: Wed, 7 Jun 2017 18:04:31 +0200 Subject: [PATCH 1/2] deuglyfied euler3.rkt --- 3/euler3.rkt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/3/euler3.rkt b/3/euler3.rkt index 55e5fbf..7f045da 100644 --- a/3/euler3.rkt +++ b/3/euler3.rkt @@ -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))) \ No newline at end of file +(max-prime-factor 600851475143) \ No newline at end of file From 10e3909ceec48850633759d39a7e6eb9d1c5b017 Mon Sep 17 00:00:00 2001 From: pikatech Date: Thu, 8 Jun 2017 21:45:05 +0200 Subject: [PATCH 2/2] Simple python one-liner. --- 1/euler1.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 1/euler1.py diff --git a/1/euler1.py b/1/euler1.py new file mode 100644 index 0000000..8ed4c84 --- /dev/null +++ b/1/euler1.py @@ -0,0 +1 @@ +sum([x for x in range(1,1000) if x % 5 == 0 or x % 3 == 0])