WAP in blue j to print all prime numbers from 1 to 1000 using for loop.
Answers
Answered by
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
2
Hi friend ☺️
Please refer to the attachment for your answer
Attachments:
Similar questions
Social Sciences,
6 months ago
Science,
6 months ago
Math,
11 months ago
Science,
1 year ago
Biology,
1 year ago