# Loop over the numbers from 2 to 499:
for PrimeTest in range(2,500):
# Assume PrimeTest prime until proven otherwise: IsPrime = 1 # 0 is false, nonzero is true
# Loop over the numbers from 2 to (PrimeTest-1): for TestFactor in range(2,PrimeTest):
# a % b equals the remainder of a/b: if (PrimeTest % TestFactor == 0):
# PrimeTest divides TestFactor (remainder is 0). IsPrime=0
break # Jump out of the innermost for-loop.
Was this article helpful?