0

Hi everyone I am learning python, I came across a sample program which checks whether the given number is prime number or is not a prime number using **for loop** and **range()** function. I can't understand that program, can someone please help me understand it? Here is the program and the output. So initially what will the variable 'n' hold?

```
for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, ’equals’, x, ’*’, n/x
... break
... else:
... # loop fell through without finding a factor
... print n, ’is a prime number’
...
#output
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
```

*Edited
by Varunkrishna*