migrate prime checker to gmpy