Last active
June 16, 2017 18:00
-
-
Save kamath/1922bf2b67760e54bebda1a663568ed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class D(dict): | |
| def __missing__(self, key): | |
| return True | |
| d = D() | |
| lim = 3000000 | |
| nums = xrange(2, lim) | |
| for a in nums: | |
| if d[a]: | |
| for b in range(a*2, lim, a): | |
| d[b] = False | |
| p = int(raw_input()) | |
| for _ in xrange(p): | |
| n = int(raw_input().strip()) | |
| if d[n]: | |
| print "Prime" | |
| else: | |
| print "Not Prime" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment