Skip to content

Instantly share code, notes, and snippets.

@ypsilon-takai
Created December 8, 2011 08:44
Show Gist options
  • Select an option

  • Save ypsilon-takai/1446478 to your computer and use it in GitHub Desktop.

Select an option

Save ypsilon-takai/1446478 to your computer and use it in GitHub Desktop.
project euler 70
;; Problem 70 : 2011/12/8
;; "Elapsed time: 19858.886534 msecs"
(defn permutation-num? [n m]
(= (sort (seq (str n)))
(sort (seq (str m)))))
(defn pe-70 [limit]
(reduce #(if (< (first %1) (first %2)) %1 %2)
(filter #(permutation-num? (second %) (last %))
(for [p1 (reverse (get-prime-list))
p2 (get-prime-list)
:while (> p1 p2)
:while (< (* p1 p2) limit)]
(let [n (* p1 p2) phi-n (* (dec p1) (dec p2))]
[(/ n phi-n) n phi-n])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment