fork(4) download
  1. def reversed_string(a_string):
  2. return a_string[::-1]
  3.  
  4. def lychrel(n):
  5. s = str(n)
  6. if s == reversed_string(s):
  7. print(s + ' é palíndromo!')
  8. return n
  9. m = int(reversed_string(s))
  10. c = m + n
  11. print(s + ' + ' + str(m) + ' = ' + str(c))
  12. return lychrel(c)
  13.  
  14. lychrel(468)
Success #stdin #stdout 0.04s 9548KB
stdin
Standard input is empty
stdout
468 + 864 = 1332
1332 + 2331 = 3663
3663 é palíndromo!