aboutsummaryrefslogtreecommitdiff
path: root/0004
diff options
context:
space:
mode:
Diffstat (limited to '0004')
-rw-r--r--0004/main.lisp14
1 files changed, 14 insertions, 0 deletions
diff --git a/0004/main.lisp b/0004/main.lisp
new file mode 100644
index 0000000..8874489
--- /dev/null
+++ b/0004/main.lisp
@@ -0,0 +1,14 @@
+(defun find-palindrome-impl (i j current-max)
+ (cond ((> j 999) current-max)
+ ((> i 999) (find-palindrome-impl 100 (+ j 1) current-max))
+ ((is-palindrome (* i j))
+ (if (> (* i j) current-max)
+ (find-palindrome-impl (+ i 1) j (* i j))
+ (find-palindrome-impl (+ i 1) j current-max)))
+ (t (find-palindrome-impl (+ i 1) j current-max))))
+
+(defun is-palindrome (x)
+ (equal (reverse (write-to-string x)) (write-to-string x)))
+
+
+(format t "~&~S~%" (find-palindrome-impl 100 100 0))