for (b = 106700; b != 123700; b += 17) { f = 1; // is b prime? for (d = 2; d != b; d++) { for (e = 2; e != b; e++) { if (d * e == b) f = 0; // nope, it's d * e } } if (f == 0) h++; } // h = numprimes([106700, 106717 ... 123700])