1. public class Prime
  2. {
  3. public static void main(String args[])
  4. {
  5. int numPrimes = 0;
  6. int currentTest = 2;
  7.  
  8. int isPrime = 1;
  9.  
  10. while (numPrimes<10000) {
  11. for (int i = 2; i < currentTest-1; i++) {
  12. if (currentTest%i == 0){
  13. isPrime = 0;
  14. break;
  15. }
  16. }
  17.  
  18.  
  19. if (isPrime == 1) {
  20. numPrimes = numPrimes + 1;
  21. System.out.println("found prime " + numPrimes + ": " + currentTest);
  22. }
  23. isPrime = 1;
  24. currentTest = currentTest + 1;
  25. }
  26.  
  27. }
  28. }