From 88e45dc7a367f081d1eb9313fff079988991f30d Mon Sep 17 00:00:00 2001 From: Lowl3v3l Date: Tue, 9 May 2017 19:48:35 +0200 Subject: [PATCH] racket solution for the third problem --- 3/euler3.rkt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 3/euler3.rkt diff --git a/3/euler3.rkt b/3/euler3.rkt new file mode 100644 index 0000000..55e5fbf --- /dev/null +++ b/3/euler3.rkt @@ -0,0 +1,14 @@ +#lang racket + +(require math/number-theory) + +(define (primes x) (filter prime? (range 2 (sqrt x)))) + +(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