Maybe not the most elegant way but it works.
public class Main {
public static void main(String[] args) {
int count = 0;
int number = 2;
while(count < 10) { int c=0;
for(int i = 2; i < number ; i++)
{
if (number%i == 0)
{
c=1;
break;
}
}
if(c==0)
{
System.out.print(number + " ");
count++;
}
number++;
}//end of while
} //end of main
} //end of class
Copyright © 2026 eLLeNow.com All Rights Reserved.