Computer Science, asked by Mewanshwa, 1 year ago

java program for generating first 100 prime numbers

Answers

Answered by saahil17
1
import java.io.*;
class Prime
{
public static void main()
{
int i,c;
for(i=0;i<=100;i++)
{
if(i%2==0)
c++;
}
System.out.println("the numbers are"+i);
}
}

saahil17: it is necessary
saahil17: it check the number of factors
Mewanshwa: But I want the prime numbers to be printed not the sum
saahil17: it isnt the sum
saahil17: c is for counting the number of factors coming....if the factors exceed 2 it wont print
saahil17: just add another else statement to it
Mewanshwa: but the printing's done outside the loop so itll print one output, right?
saahil17: no i dont think so
Mewanshwa: can u just do me a favor and try it on ur computer?plsss
saahil17: i dont have bluej on my computer
Similar questions