if statment not responding (python)
<p>the if statement is not responding. I'm trying to get the <code>gcd(20,6)</code>
the program outputs: <code>gcd(20,6): 20=6(4) + -3</code>, I need it to be if the last number(-3) is less than 0 the the program should output <code>20=6(3) + 3</code>,but the if statement isn't responding. thanks</p>

<pre><code>rnumtup = (20, 6)
if rnumtup[0] &gt; rnumtup[1]:
    x= rnumtup[1]
    y =rnumtup[0]
w = x / y
w = round(w)
z = x - (y*w)
z = round(z)

while z != 0:
    x = y
    y = z
    w = x / y
    w = round(w)
    z = x - (y*w)
    z = round(z)
    if z &gt; 0: #not responding
        #some statements
    if z &lt; 0: #not responding
        #some statements
</code></pre>

<p>You would think that z cannot be 0 because of </p>

<pre><code>while z!=0:
</code></pre>

<p>but when your program reaches the statement</p>

<pre><code>z= round(z)
</code></pre>

<p>z can be 0 and you program checks only for strictly positive or negative numbers since 0>0 is false, a better gdc function would be <a href="https://en.wikipedia.org/wiki/Euclidean_algorithm" rel="nofollow">euclid's algorithm</a>, here is the python 3 version</p>

<pre><code>def gdc(a,b):
   while a!=b:
      if a&gt;b:
         a=a-b
      else:
         b=b-a
   return a
print(gdc(20,6))
</code></pre>

python