forked from printf-twinkle/hacktoberfest-contribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.java
More file actions
33 lines (27 loc) · 655 Bytes
/
prime.java
File metadata and controls
33 lines (27 loc) · 655 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
import java.util.Scanner;
public class prime{
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int number;
int count=0;
int i;
System.out.print("Enter a Number you want to check : ");
number = scan.nextInt();
for(i=2; i<number; i++)
{
if(number%i == 0)
{
count++;
break;
}
}
if(count == 0)
{
System.out.print("This is a prime number");
}
else
{
System.out.print("This is not a prime number");
}
}
}