write a to print first 10 palindrome prime number using user defined function eg. 131 which is a palindrome as well as a prime number.
for java . please provide answer do not spam .
Answers
Explanation:
package mypackage;
import java.util.Scanner;
public class ppp {
int rem,n1,rev=0,N,i;
public static void main(String[] args) {
/* write a to print first 10 palindrome prime number using user defined function eg. 131 which is a palindrome as well as a prime number for java .*/
ppp cc=new ppp() ;
cc.input();
cc.x1();
cc.x2();
}
public void input(){
Scanner obj= new Scanner(System.in);
System.out.print("Enter a number: ");
N=obj.nextInt();
}
public void x1(){
int c=0;
for(i=1;i<=N;i++){
if(N%i==0){
c++;
}
}
if(c==2){
System.out.println("Prime Number.");
}
else{
System.out.println("Composite Number. ");
}
}
public void x2(){
n1=N;
while(N>0){
rem=N%10;
rev=(rev*10)+rem;
N=N/10;
}
if(rev==n1){
System.out.println("Palindrome Number.");
}
else{
System.out.println("Not a Palindrome Number.");
}
}
}