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")

Comments

Popular posts from this blog

Create account in java |deposit money|withdraw money

Library Management System in python OOPs Concept

List comprehension hackerrank solution in python