-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathPrimeNumber.java
More file actions
31 lines (30 loc) · 780 Bytes
/
PrimeNumber.java
File metadata and controls
31 lines (30 loc) · 780 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author DELL
*/
public class PrimeNumber
{
public static void main(String[] args)
{
int i,m=0,flag=0;
int n=3;//it is the number to be checked
m=n/2;
if (n==0||n==1){
System.out.println(n+" is not prime number");
}else{
for(i=2;i<=m;i++){
if(n%i==0){
System.out.println(n+" is not prime number");
flag=1;
break;
}
}
if (flag==0) { System.out.println(n+" is prime number"); }
}
}
}