class Prime2{
public static void main(String args[])
{
System.out.println("Prime numbers between 1 to 100 are:");
int i=1,c=0,j;
for(;i<=100;i++)
{
for(j=2;j<=i/2;j++)
if(i%j==0)
c++;
if(c==0)
System.out.print(i+" ");
c=0;
}
}
}
public static void main(String args[])
{
System.out.println("Prime numbers between 1 to 100 are:");
int i=1,c=0,j;
for(;i<=100;i++)
{
for(j=2;j<=i/2;j++)
if(i%j==0)
c++;
if(c==0)
System.out.print(i+" ");
c=0;
}
}
}
No comments:
Post a Comment