main.lisp 502 B

1234567891011121314
  1. (defun find-palindrome-impl (i j current-max)
  2. (cond ((> j 999) current-max)
  3. ((> i 999) (find-palindrome-impl 100 (+ j 1) current-max))
  4. ((is-palindrome (* i j))
  5. (if (> (* i j) current-max)
  6. (find-palindrome-impl (+ i 1) j (* i j))
  7. (find-palindrome-impl (+ i 1) j current-max)))
  8. (t (find-palindrome-impl (+ i 1) j current-max))))
  9. (defun is-palindrome (x)
  10. (equal (reverse (write-to-string x)) (write-to-string x)))
  11. (format t "~&~S~%" (find-palindrome-impl 100 100 0))