Palindrome number using recursion
def palindrome(n,r):
if n==0:
return r
else:
r=n%10+r*10
return palindrome(n//10,r)
n=1001
r=0
res=palindrome(n,r)
if n==res:
print(res,"is palindrome")
else:
print(res,"is not palindrome")
def palindrome(n,r):
if n==0:
return r
else:
r=n%10+r*10
return palindrome(n//10,r)
n=1001
r=0
res=palindrome(n,r)
if n==res:
print(res,"is palindrome")
else:
print(res,"is not palindrome")
Comments
Post a Comment
If you have any doubt you ask me in comment section