# Code is not printing the correct statement and doesn't stop (python)

I am writing a code that in the end will print the first number that is not prime. It starts at 10 and goes up to 200 and uses an equation num^2-(79*num)+1601 . So in my case the output should stop at 80 and print that it is not a prime number, since 80^2-79(80)+1601= 1681 which is not prime. For some reason as it is now it just runs from 10 to 200 without stopping and only prints what is prime. Thanks in advance for the help!!

``````import math
#variables
isPrime=True
result=0
num=10
i=2
#loop to start from 10 to 200 and calculate result for equation
while(num>=10 and num<=200):
#equation
result=num**2-(79*num)+1601
#check if result is divisible by 2 (evenly)
if result%2==0:
isPrime=False
break
#start divisor at 3 and increase by 2 so it can skip even numbers
sqrt=math.sqrt(result)
for i in range(3, i<sqrt, 2):
if result % i==0:
isPrime=False
break
#break
#print the first not prime number
if isPrime==False:
print("{num} is n in the equation and the result is {result} which is not a prime number".format(num=num,result=result,i=i))
else:
print("{num} is n in the equation and the result is {result} which is a prime number ".format(num=num,result=result))
break
num=num+1

``````

What part of your code would make it stop at 80? Please argue for what you think should happen, that doesn’t.
It only does one iteration, that’s not what you described, wrong code?
If it is your intention to test for whether `result` is prime, you could greatly reduce clutter in your function by creating a `is_prime` function (It’s currently non-obvious what your loop does because of the high amount of conditional branches)

Figured it out, thanks.