Python Set Comprehension
primes = {x for x in range(2, 101) if all(x%y for y in range(2, min(x, 11)))} I simplified the test a bit – if all(x%y instead of if not any(not x%y I also limited y’s range; there is no point in testing for divisors > sqrt(x). So max(x) == 100 implies max(y) == 10. For … Read more