import java.io.*;
class prime_series
{
public static void main(String args[])
{ int st,end;
int flag=0;
DataInputStream in=new DataInputStream(System.in);
System.out.print("Enter starting range: ");
st=Integer.parseInt(in.readLine());
System.out.print("\nEnter ending range: ");
end=Integer.parseInt(in.readLine());
for(int i=st;i<=end;i++)
{
for(int j=2;j<=i/2;j++)
{ if(i%j==0)
{ flag=1;
break;
}
else
flag=0;
}
if(flag==0)
System.out.print(i + " ");
}
}
}
Comments
Post a Comment