Java Program for Prime Numbers between 1 to 100


This program will give you prime numbers between 1 to 100.

class Prime
{
public static void main(String args[])
{
int i,c,j;
System.out.println(” prime numbers are:”);
for(i=2;i<=100;i++)
{c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
{
c++;
}
}
if(c==2)
{
System.out.print(”  ” + i);
}

}
}
}

Add Comment