Created
February 12, 2013 06:00
-
-
Save jordangarcia/4760553 to your computer and use it in GitHub Desktop.
This file contains 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
(ns test1.prob4) | |
(defn palindromic-number? [x] | |
(let [arr (vec (.toString x)), size (count arr)] | |
(loop [x 0] | |
(if (not= (get arr x) (get arr (- size x 1))) | |
false | |
(if (> x (/ size 2)) | |
true | |
(recur (inc x))))))) | |
(defn prob4 [start] | |
(loop [x start, y start] | |
(println (str x " " y)) | |
(def results []) | |
(if (palindromic-number? (* x y)) | |
(conj results (* x y))) | |
(if (and (= x 1) (= y 1)) | |
results | |
(if (= x 1) | |
(recur start (dec y)) | |
(recur (dec x) y))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment