while x > 1:
n = range(2, (x - 1))
for i in n:
if x % n == 0:
When I click on "save and submit", it runs forever and won't show the result.
I wanted to code the following logic.
- while input, x, is greater than 1, if any number ranging from 2 to x-1 can divide x evenly, it is not a prime number. Hence, False.
- in all other cases, i.e., if x ==1 or x cannot be divided evenly by 2 to x-1, it should be a prime number.
What is wrong with my code?
Replace this line with your code.