(Sep-11-2018, 07:55 PM)Johne1 Wrote: First line of output should always be: n=2, x=2 (this is never output!)if n=2 then in the inner loop x will try to iterate over range(2,2). However range(2,2) is empty one:
>>> list(range(2,2)) []so the loop body (lines 3-8) is never executed (and thus no break statement) so else part (lines 10-11) is executed and it prints that 2 is prime number
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs