Given an integer, write a function that returns true if the given number is palindrome, else false. For example, 12321 is palindrome, but 1451 is not palindrome.
Let the given number be num. A simple method for this problem is to first reverse digits of num, then compare the reverse of num with num. If both are same, then return true, else false.
Examples:
Input : 12221 Output : true Input : 12345 Output : false
Below is the required implementation:
declare -- declare variable n, m, temp -- and temp of datatype number n number; m number; temp number:=0; rem number; begin n:=5432112345; m:=n; -- while loop with condition till n>0 while n>0 loop rem:=mod(n,10); temp:=(temp*10)+rem; n:=trunc(n/10); end loop; -- end of while loop here if m = temp then dbms_output.put_line('true'); else dbms_output.put_line('false'); end if; end; / -- Program End |
Output:
true
Recommended Posts:
- Check if a number is Palindrome
- Check if number is palindrome or not in Octal
- Program to check the number is Palindrome or not
- Recursive program to check if number is palindrome or not
- Check whether the given floating point number is a palindrome
- To check a number is palindrome or not without using any extra space
- Generate number with given operation and check if it is palindrome
- Bash program to check if the Number is a Palindrome
- Check if a number with even number of digits is palindrome or not
- Check if actual binary representation of a number is palindrome
- Check if string remains palindrome after removing given number of characters
- Check if sum of any subarray is Palindrome or not
- Check if a given string is Even-Odd Palindrome or not
- Check whether a string is palindrome or not in PL/SQL
- Check if the sum of digits of N is palindrome
- Check given string is oddly palindrome or not | Set 2
- C Program to Check if a Given String is Palindrome
- Check if all elements of the array are palindrome or not
- Check if both halves of a string are Palindrome or not
- Queries to check if substring[L...R] is palindrome or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

