diff --git a/euler3.scm b/euler3.scm new file mode 100644 index 0000000..208fec1 --- /dev/null +++ b/euler3.scm @@ -0,0 +1,16 @@ +(define (factors n) + (let loop ((val n) (div 2) (factors '())) + (if (= 1 val) + factors + (if (= 0 (modulo val div)) + (loop (/ val div) div (cons div factors)) + (loop val (add1 div) factors) + ) + ) + ) +) + +(define (max lst) + (foldl (lambda (a b) (if (> a b) a b)) (car lst) (cdr lst))) + +(print (max (factors 600851475143))) \ No newline at end of file