optimizations to check prime faster. two optimized methods