Computer Science, asked by SnehalD, 11 months ago

WAP in blue j to print all prime numbers from 1 to 1000 using for loop.

Answers

Answered by devasya619
1

Answer:

class prime1To1000

{

public static void main()

{

int i,k,j;

for(i=1;i<1000;i++)

{

k=0;

for(j=2;j<i;j++)

{

if(i%j==0)

{

k=1;

break;

}

}

if(k==0)

{

System.out.println(i);

}

}

}

}

Answered by phenomenalguy
2

Hi friend ☺️

Please refer to the attachment for your answer

Attachments:
Similar questions