Palindrome program in Python using recursive method
In this tutorial you will learn how to write a program in Python to check a given number is palindrome or not using recursive method.
Before moving directly on the writing the program to check whether a given number is palindrome or not using recursion, you should know
What is Palindrome Number?
A Palindrome number is a number which reverse is equal to the original number means number itself.
For example : 121, 111, 1223221, etc.
In the above example you can see that 121 is a palindrome number. Because reverse of the 121 is same as 121.
How our program will behave?
Suppose if someone gives an input 121 then our program should print “the given number is a palindrome”.
And if someone given input 123 the our program should print “the given number is not a palindrome number”.
Python program for palindrome number using recursive method
n = int(input("please give a number : ")) def reverse(num): if num<10: return num else: return int(str(num%10) + str(reverse(num//10))) def isPalindrome(num): if num == reverse(num): return 1 return 0 if isPalindrome(n) == 1: print("Given number is a palindrome") else: print("Given number is a not palindrome")
Also prepare these Python Programs:
Latest Uploads on Website
- AVL Tree with explanation
- Radix sort algorithm explanation with example
- Quick Sort Algorithm with explanation
- Bubble sorting algorithm with Bubble sort program in C
- Insertion sort algorithm and program in C
- Selection Sort Algorithm and Program in C
- Linear probing technique explanation with example
- Collision in Hashing and Collision resolution technique
- Hashing in data structure with its types
- Binary search tree operations with Program
- Binary search tree in data structure
- Binary search algorithm in data structure with explanation
- linear search in data structure with Algo and Program