Mar-01-2018, 04:09 AM
for n in range(2, 10):this is going to iterate over a range from 2 to 10
so n will be equal to 2, 3, ... up to 9 (1 less than final number because range is zero based)
for x in range(2, n):this does the same from 2 to n, and will fully execute for each iteration of the outer loop
but this time terminates on n - 1, and output goes to x
if n % x == 0:this statement used the '%' modulo operator.
It says, if n mod x == 0 which is true if both x and n are equal
modulo division yields the remainder from the division of the first argument by the second
print n, 'equals', x, '*', n/xso if n and x are the same, above gets printed
else: print n, 'is a prime number'and if not equal prints this