>>115
    for (i = 2; i <= upper / 2; i++) {
+        if (!integers[i]) continue;
        notprime = i;

これがないと篩になってないかと。