Computer Science, asked by mohammadadnan7, 4 months ago

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

Answered by abhinabchoudhury29
1

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.");

}

}

}

please give my answer the Brainlyiest answer and follow me and give me a thanks.

Attachments:
Similar questions