You are viewing a single comment's thread. Return to all comments →
import math def is_prime(n: int) -> str: if n == 1: return "Not prime" ans = ( next( filter( lambda x: n % x == 0, (div for div in range(2, math.floor(math.sqrt(n) + 1))) ), None ) ) return "Prime" if ans is None else "Not prime" tests = [int(input()) for i in range(int(input()))] for test in tests: print(is_prime(test))
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 →