write a program in java to find prime numbers till 100
Answers
Answered by
5
class PrimeNumbers100
{
public static void main(String args[] )
{
int i,j,x,m;
System.out.println("Prime Numbers up to 100 are\n");
System.out.print("2"+ " ");
System.out.print("3"+ " ");
for(i=4;i<=100;i++)
{
x=0;
for(j=2;j<=i-1;j++)
{
m=i%j;
if(m==0)
{
x=1;
break;
}
}
if(x==0)
{
System.out.print(i + " ");
}
}
}
}
{
public static void main(String args[] )
{
int i,j,x,m;
System.out.println("Prime Numbers up to 100 are\n");
System.out.print("2"+ " ");
System.out.print("3"+ " ");
for(i=4;i<=100;i++)
{
x=0;
for(j=2;j<=i-1;j++)
{
m=i%j;
if(m==0)
{
x=1;
break;
}
}
if(x==0)
{
System.out.print(i + " ");
}
}
}
}
braniest:
Thank you very much
Similar questions