A prime check that fails at the boundary
Predict the output · Medium · §7.6 Nested loops and the first math helper
The part of this prime check that first filters out numbers of 1 or less has been removed. Predict the output when n is 1.
Code
n = 1
is_prime = True
for i in range(2, n):
if n % i == 0:
is_prime = False
break
print(n, is_prime)Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.