forked from deepanshdubey/JavaAssignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckPrime.java
More file actions
32 lines (29 loc) · 753 Bytes
/
CheckPrime.java
File metadata and controls
32 lines (29 loc) · 753 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
//Author : Deepansh Dubey.
//Date : 2/09/2021.
//Purpose : To check whether a is prime or not.
import java.io.*;
class CheckPrime
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int p,i,k=0;
System.out.println("Please enter the no.");
p=Integer.parseInt(br.readLine());
for(i=1;i<=p;i++)
{
if(p%i==0)
{
k++;
}
}
if (k==2)
{
System.out.println("It's a PRIME number.");
}
else
{
System.out.println("It's NOT a PRIME number.");
}
}
}