Java : How to check palindrome number or not in java program #learnjava #coding #palindromenumber

0

Java Program to check Palindrome  Number or Not

 

#palindromeNumber

PALINDROME NUMBER DEFINATION

A palindrome number is a positive integer that remains unchanged when its digits are reversed. In other words, the number reads the same from left to right as it does from right to left.


Properties of Palindrome Number:-  

A palindrome number with an even number of digits is always divisible by 11. For example, 242 is divisible by 11 (22 * 11 = 242).

A palindrome number with an odd number of digits is divisible by 11 if the sum of its odd-positioned digits minus the sum of its even-positioned digits is divisible by 11.


The following Java program print  the Palindrome numbers or not Palindrome number ......

Example 

   class Palindrome{
    public static void main(String[] args)
     {
        int num=121, temp=num,r=0,sum=0;
        while(temp>0)
        {
            r=temp%10;
            sum=r+(sum*10);
            temp=temp/10;
        }
        if (num==sum) {
            System.out.println("Palindrome number...");
        }
        else
        {
            System.out.println("not palindorme Number...");
        }

    }
} 
 

  output

Palindrome number...


Related Post  







Post a Comment

0Comments
Post a Comment (0)