Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

palindrome of a number in python using recursion

def reverse(n, rev=0):
    if n == 0:
        return rev 
    rev = rev * 10 + (n % 10)
    rev = reverse(n // 10, rev)
    return rev
n = int(input("Enter a no.:"))
if n == reverse(n):
    print(n,' is a Palindrome')
else:
    print(n,' is not a Palindrome')
Source by www.thecodeteacher.com #
 
PREVIOUS NEXT
Tagged: #palindrome #number #python #recursion
ADD COMMENT
Topic
Name
6+9 =