You are viewing a single comment's thread. Return to all comments →
Python
from math import ceil, sqrt def prime(x): if x == 2: return "Prime" elif x == 1 or (x & 1) == 0: return "Not prime" for i in range(2, ceil(sqrt(x)) + 1): if x % i == 0: return "Not prime" return "Prime" print('\n'.join([prime(int(input())) for _ in range(int(input()))]))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 25: Running Time and Complexity
You are viewing a single comment's thread. Return to all comments →
Python