forked from deepanshdubey/JavaAssignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimeSeries.java
More file actions
31 lines (29 loc) · 710 Bytes
/
PrimeSeries.java
File metadata and controls
31 lines (29 loc) · 710 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
//Author : Deepansh Dubey.
//Date : 2/09/2021.
//Purpose : To print prime numbers upto n.
import java.io.*;
class PrimeSeries
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int p,i,j,k=0;
System.out.println("Please enter the no.");
p=Integer.parseInt(br.readLine());
for(i=2;i<p;i++)
{
for(j=1;j<=i;j++)
{
if(i%j==0)
{
k++;
}
}
if (k==2)
{
System.out.print("\t"+i);
}
k=0;
}
}
}