blob: 09408a929968fb0e26d670d23162cb22195f9545 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
(define (palindrome? x)
(define (rev x ans)
(if (= x 0)
ans
(let ((r (remainder x 10)))
(rev (/ (- x r) 10) (+ r (* ans 10))))))
(= (rev x 0) x))
(define (bigpal ans x y)
(if (> x 999)
ans
(if (> y 999)
(bigpal ans (+ x 1) (+ x 1))
(if (and (palindrome? (* x y)) (> (* x y) ans))
(bigpal (* x y) x (+ y 1))
(bigpal ans x (+ y 1))))))
(display (bigpal 0 100 100))
(newline)
|