Created
December 8, 2011 08:44
-
-
Save ypsilon-takai/1446478 to your computer and use it in GitHub Desktop.
project euler 70
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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