application/octet-stream
•
627 B
•
22 lines
;; The biggest product of 2 3-digit numbers that is a palindrome
;; https://projecteuler.net/problem=4
[defn reverse-num [a]
[def ret 0]
[while [> a 0]
[set! ret [+ [* ret 10] [rem a 10]]]
[set! a [div/int a 10]]]
[return ret]]
[defn palindrome? [a]
[== a [reverse-num a]]]
[def max 0]
[dotimes [a 1000]
[dotimes [b 1000]
[def p [* a b]]
[when [and [palindrome? p]
[> p max]]
[set! max p]]]]
[pfmtln "The biggest product of 2 3-digit numbers that is a palindrome is: {max}"]