# Write a program to find if a number is Lychrel Number in Python

Upasana | May 05, 2019 | 1 min read | 99 views |

Lychrel number is a natural number that cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. for example,

• 56 becomes palindromic after one iteration: 56+65 = 121.

• 57 becomes palindromic after two iterations: 57+75 = 132, 132+231 = 363.

Lychrel Number: Python implementation
``````def reverse(num):
rev = 0
while(num > 0):
rem = num %10
rev = (rev *10) + rem
num = num //10
return rev

def check_palindrome(num):
temp = num
rev = 0

while temp != 0:
rev = (rev * 10) + (temp % 10)
temp = temp // 10

if num == rev:
return False
else:
return True

def lychrel_num(num):
i = 0
type = str(num) + " is a lychrel number"
while check_palindrome(num):
num = num + reverse(num)
i =i+1
if i == 10:
type = str(num) + " is not a lychrel number"
break
return i, num, type

print(lychrel_num(196))
print(lychrel_num(87))``````
Output
```(10, 18211171, '196 is not a lychrel number')
(4, 4884, '87 is a lychrel number')```

##### Top articles in this category:

###### Recommended books for interview preparation:
Book you may be interested in..
Book you may be interested in..