Net Beans Program to Generate Prime No. upto a Limit
private void CheckActionPerformed(java.awt.event.ActionEvent evt)
{
int N= Integer.parseInt(t1.getText());
int i,p;
if (N==1)
r.setText("One Is Unique Number");
for (p=2;p<=N;p++)
{
for(i=2;i<=p/2;i++)
{
if(p%i==0)
break;
}
if(i>p/2)
r.append(p+"\n");
}
}
private void ClearActionPerformed(java.awt.event.ActionEvent evt) {
t1.setText("");
r.setText("");
Comments
Post a Comment