(use-modules (ice-9 time))

(define (revnum x)
  (string->number
   (list->string
    (reverse
     (string->list
      (number->string x))))))

(define (testL x n)
  (define x_ (revnum x))
  (if (> n 50) #t
       (if (equal? x x_) #f
          (testL (+ x x_) (+ n 1)))))

(define (test x n lis)
  (define x_ (revnum x))
  (if (> n 50) lis
      (if (equal? x x_) (append lis (list x))
          (test (+ x x_) (+ n 1) (append lis (list x))))))

(define (isL x)
  (set! x (+ x (revnum x)))
  (testL x 1))

(define (main x n lis)
  (if (> x n) lis
      (main (+ x 1)
            n
            (if (isL x) (append lis (list x))
                  lis))))

(define (showlist x)
  (display (car x))
  (newline)
  (if (> (length x) 1)
       (showlist (cdr x))
      "end"))

(main 1 10000 ())