import java.io.*;
import java.io.DataInputStream;
class primeno
{
int n,i=0,j=2,f;
void read()
{
try
{
System.out.println("enter the limit");
DataInputStream in=new DataInputStream(System.in);
n= Integer.parseInt(in.readLine());
}
catch(Exception e)
{
System.out.println("caught exception"+e);
}
}
void gen()
{
while(i<n)
{
f=1;
for(int k=2;k<=(j/2);k++)
{
if(j%k==0)
{
f=0;
break;
}
}
if(f==1)
{
i++;
System.out.println(+j);
}
j++;
}
}
}
class prime
{
public static void main(String args[])
{
primeno p=new primeno();
p.read();
p.gen();}}
OUTPUT:
0 comments:
Post a Comment