forked from anisul-Islam/java-documentation-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram24.java
More file actions
29 lines (26 loc) · 698 Bytes
/
Copy pathProgram24.java
File metadata and controls
29 lines (26 loc) · 698 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
import java.util.Scanner;
//prime number or not
public class Program24 {
public static void main(String[] args) {
try (Scanner input = new Scanner(System.in)) {
System.out.print("Enter a positive integer: ");
int number = input.nextInt();
int count=0;
if(number==0 || number ==1){
System.out.println("Not Prime number");
}else{
for(int i=2; i< number ; i++){
if(number%i == 0){
count++;
break;
}
}
if(count==0){
System.out.println("Prime number");
}else{
System.out.println("Not Prime number");
}
}
}
}
}