 
 ;; Find ∑c for c < 120000.
 
+;; From problem 0010 :
+;; -------------------
+(defn prime?
+  [n]
+  {:pre [(integer? n) (> n 0)]}
+  (or (== 2 n)
+      (let [mmax (+ (Math/sqrt n) 1)]
+        (not (some #(== 0 (rem n %)) (concat [2] (range 3 mmax 2))))
+        )))
+
+(defn lz-primes
+  []
+  (concat [2]
+          (filter prime? (iterate #(+ 2 %) 3))))
+
+;;---------------------------------------------------------------------------
+
+(def primes (->> (lz-primes)
+                 (take-while #(< % 120000))
+                 (vec)
+                 ))
+
+(defn abc-hit? [[a b c]]
+  (and (== 1 (gcd a b))
+       (== 1 (gcd a c))
+       (== 1 (gcd b c))
+       (< a b)
+       (== (+ a b) c)
+       (< (rad (* a b c)) c)
+       ))
+
 (defn gcd [x y]
   (if (zero? y)
     x
     (recur y (rem x y))))
+
+(defn decompose [x]
+  (loop [x x
+         ps primes
+         q 0
+         r 1
+         upfs []
+         mpfs []]
+    (let [p (first ps)]
+      (cond (> (* p p) x)   (if (== x q)
+                              [r upfs (conj mpfs x)]
+                              [(* r x) (conj upfs x) mpfs])
+            (< 0 (rem x p)) (recur x          (rest ps) p r        upfs          mpfs)
+            (== p q)        (recur (quot x p) ps        p r        upfs          (conj mpfs p))
+            :else           (recur (quot x p) ps        p (* r p) (conj upfs p)  mpfs)
+            ))))
+
 
 (defn rad [x]
   (loop [x x p 2 q 0 r 1]

(ns project-euler.problem_0127)

;; The radical of n, rad(n), is the product of distinct prime factors of n.
;; For example, 504 = 2^3 × 3^2 × 7, so rad(504) = 2 × 3 × 7 = 42.

          (== p q)        (recur (quot x p) p                       p r)
          :else           (recur (quot x p) p                       p (* r p))
        )))



(defn naive-solution-for [c-max]
  (->> (range 3 c-max)
