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
(fn [x n] | |
(loop [res (), k 0] | |
(cond (>= k n) (if (list? x) res (reverse res)) | |
:else (recur (conj res (filter #(= k (mod % n)) x)) (inc k))))) |
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
(defn is-palindrome [x] | |
(= x (Integer/parseInt (apply str (reverse (str x))))) | |
) | |
(defn problem4 [] | |
;Find the largest palindrome made from the product of two 3-digit numbers. | |
(def max-palindrome 0) | |
(doseq [i (range 999)] | |
(doseq [j (range i)] | |
(do |
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
(defn get-prime-factors [n-arg] | |
;(def n n-arg) | |
(def prime-factors (list)) | |
(loop [p 2 n n-arg :while (> n 1)] | |
(println (str "p=" p " n=" n)) | |
;(while (> n 1) | |
(println n) | |
(println (class n)) | |
(if (= 0 (mod n p)) |
NewerOlder