Finally got my off-by-one error fixed. Slow, since we're using a very naive solution (should use sieve of atkin or eratosthenes, but 2mil is not too large a number), but works