## Program for palindrome number in java

In the following question, we are supposed to ask the user for an Integer input and then check if it is a Palindrome Number.

*Palindrome Number are those numbers which when reversed are identical to the original number.*

**Example:** 2576752 when reversed will be 2576752, thus it is a Palindrome Number.

The standard algorithm will be:

- Enter and Store the Integer Input.
- Store the same input in a duplicate variable for later use.
- Use a While loop which will run until N is reduced to 0.
- Construct to extract each individual digit from the extreme right using modulus operator.
- Keep Accumulating it in a separate variable within the loop construct.
- After the loop terminates, finally compare if the resulting number is equivalent to the original number.
- If the result is true, it is a Palindrome Number.
- Print the result accordingly.

### Java code:

```
/* Program to check if a number is Palindrome or not.
* Palindrome Numbers are numbers which if reversed will result in the original number.
Example: 11,121,1331,159951,4378734,etc. */
import java.util.*;
class Palindrome {
public static void main() {
Scanner inp = new Scanner(System.in);
System.out.print("\n Enter Number: ");
int n = inp.nextInt();
int a, s = 0, m = n;
while (n != 0) // Extracting each digits and accumulating its sum.
{
a = n % 10;
s = s * 10 + a;
n = n / 10;
}
if (m == s) // Checking if reverse and original are identical.
System.out.println(m + " is a Palindrome Number");
else
System.out.println(m + " is not a Palindrome Number");
}
}
```

### Output:

```
Enter Number: 3625263
3625263 is a Palindrome Number
Enter Number: 4472414
4472414 is not a Palindrome Number
```

Report Error/ Suggestion