Write a menu driven class to accept a number from the user and check whether it is a palindrome or a prefect number. a.Palindrome number-(a plindrome number when read in the reverse order is same as when read in the right order)Example:11,101,151,etc.
b.Prefect number-(a number is called Prefect if it is equal to the sum of its factors other than the number itself)Example:6=1+2+3
Answers
Answered by
2
Answer:
palindrome no.
Explanation:
int n=Integer.parseInt(br.readLine());
//input the no. in 'n'
int r=0; int copy=n;
while(n>0)
{d=n%10;
r=r*10+d;
n/=10;
}
if(r==copy)
System.out.println(n+"is a aplindrome no.");
else
System.out.println(n+"is not apalindrome no.");
Similar questions