-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperPrimeNumber.java
More file actions
48 lines (42 loc) · 860 Bytes
/
SuperPrimeNumber.java
File metadata and controls
48 lines (42 loc) · 860 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
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.Scanner;
public class SuperPrimeNumber {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Enter a Number");
int no=sc.nextInt();
if(isSuperPrimeNo(no)) {
System.out.println(no+" is Super Prime Number");
}
else {
System.out.println(no+" is not a Super Prime Number");
}
}
public static boolean isSuperPrimeNo(int no) {
if (isPrimeNo(no)&&isPrimeNo(PrimePosition(no))) {
return true;
}
return false;
}
public static boolean isPrimeNo(int no) {
if (no<=1) {
return false;
}
for (int i=2;i<=no/2 ;i++ ) {
if (no%i==0) {
return false;
}
}
return true;
}
public static int PrimePosition(int no) {
int position=0;
int num=2;
while(no>=num){
if (isPrimeNo(num)) {
position++;
}
num++;
}
return position;
}
}