Commits

Victor Iacoban committed 8d9e0a4

26 cracked

Comments (0)

Files changed (2)

src/main/clojure/euler/prob026.clj

+(ns euler.prob026
+  (:use tools.primes))
+
+(defn recurring-size [n]
+  (if-not (is-prime? n)
+    [false 0 n :not-prime]
+    (loop [i 1]
+      (let [d (.pow 10M i)]
+        (cond
+          (zero? (mod d n)) [false i n]
+          (zero? (mod (dec d) n)) [true i n]
+          :else (recur (inc i)))
+        ))))
+
+(defn euler26 [n]
+  (->> (range 2 n)
+    (map recurring-size)
+    (filter first)
+    (sort-by second >)
+    (first)))

src/main/clojure/tools/primes.clj

-(ns euler.primes)
+(ns tools.primes)
 
 (defn prime-decomposition
   ([n] (prime-decomposition n 2))