-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimepa.java
More file actions
35 lines (33 loc) · 932 Bytes
/
Primepa.java
File metadata and controls
35 lines (33 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
class Primepa{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("enter the number");
int n=sc.nextInt();
int count=0;
for (int i = 2; i < n/2; i++){
if(n%i==0){
count++;
break;
}
}
if(count==0) { System.err.println("prime number");
int r=0;
int t=n;
while(n!=0){
int d=n%10;
r=r*10+d;
n=n/10;
}
System.out.println("the reverse of the given number is "+r);
if(r==t){
System.err.println("the number is palindrome");
}
else{
System.err.println("the number is not a palindrome");
}
}
else{
System.err.println("not a prime number");}
}
}