Find Prime Numbers up to the given Number

import javax.swing.JOptionPane;
import java.io.*;
class Prime1
{
public static void main(String[] args) throws IOException
{
        String N;
int i,j,count=0,n;
String output="prime numbers are";
N=JOptionPane.showInputDialog("enter n value");
n=Integer.parseInt(N);
for(i=1;i<=n;i++)
{
count=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count==2)
output=output+" "+i;
}
JOptionPane.showMessageDialog(null,output,"Message",JOptionPane.INFORMATION_MESSAGE);
}
}

All Rights Reserved The Origin for Screamers | Design by SCREAMERS
Computers
Top Blogs