import java.io.*; public class PrimeCount { private static int lastTested = 1; // last number tested private static int primeCount = 0; // number of primes found private static boolean isPrime(int n) { if(n < 2) { return false; } else { for(int i = 2; i * i <= n; i++) { if(n % i == 0) return false; } return true; } } public static void main(String[] args) { // The following code illustrates only the usage of // isPrime, and it will probably *NOT* be in your // main method. Please delete any unused code and this comment. while(true) { if(isPrime(lastTested + 1)) { ++primeCount; } ++lastTested; System.out.println(primeCount + " primes <= " + lastTested); } } }