forked from mayankgb2/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.java
More file actions
24 lines (21 loc) · 605 Bytes
/
prime.java
File metadata and controls
24 lines (21 loc) · 605 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
//https://www.facebook.com/honey.agrawal.12935/posts/770711770445417
// Subscribed by 1MS19CS135 Utkarsh
public class Main {
public static void main(String[] args) {
int num = 29;
boolean flag = false;
for(int i = 2; i <= num/2; ++i)
{
// condition for nonprime number
if(num % i == 0)
{
flag = true;
break;
}
}
if (!flag)
System.out.println(num + " is a prime number.");
else
System.out.println(num + " is not a prime number.");
}
}