Computer Science, asked by braniest, 1 year ago

write a program in java to find prime numbers till 100

Answers

Answered by Sandy260
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 + " ");
}
}
}
}

braniest: Thank you very much
braniest: i am in 7th and this question was difficult for me
Aasthapatil12345: anytime☺☺
Sandy260: Umm aastha Patil I answered the question
braniest: thanks sandy
Sandy260: Your welcome
Similar questions