-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain26.java
More file actions
33 lines (21 loc) · 742 Bytes
/
Main26.java
File metadata and controls
33 lines (21 loc) · 742 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
package loopinjava;
import java.util.Scanner;
public class Main26 {
public static void main(String[] args) {
int n, number, isPrime = 1;
Scanner input = new Scanner(System.in);
System.out.println("Check whether a number is Prime number or not.\n");
System.out.print("Enter a number: ");
number = input.nextInt();
for (n = 2; n < number; n++) {
if (number % n == 0) {
isPrime = 0;
}
}
if (isPrime == 1) {
System.out.println(number + " is prime a number.\n");
} else {
System.out.println(number + " is prime not a number.\n");
}
}
}