title: Python-array about gcd
body: <p><a href="https://i.stack.imgur.com/BQVNS.jpg" rel="nofollow noreferrer">Q</a>
  I tried many ways but it didn't work. please show me a way.</p>
  
  <p>My last code that I tried;</p>
  
  <pre><code>n = int(sys.argv[1])
  
  x = stdarray.create2D(n,n,0)
  
  
  for i in range(n):
      for j in range(n):
          if i &gt; j:
              while j != 0:
                  z = i % j
                  i = j
                  j = z
          elif j &gt; i:
              while i != 0:
                  z = j % i
                  j = i
                  i = z
          if i == 1 or j == 1:
              stdio.write("* ")
          else:
              stdio.write(" ")
      stdio.writeln()
  </code></pre>
  
  <p>And I explain some details from my codes, I use different library than normal.
  stdio.writeln is like print. you should think it is print...</p>
  
  <p>and stdarray.create bla bla is a array.
  first n is represent: row
  second n is represent: column
  so it will be square matrix as you can see. (because both of them are "n")</p>
  
  <p>and my code's output is; if i entered 5 in argv. it will be 5x5 matrix. and output is; </p>
  
  <pre><code>0 1 2 3 4 
  1 1 1 3 4
  2 1 1 3 4
  3 1 1 3 4
  4 1 1 3 4
  </code></pre>
  
  <p>But it's wrong. for example a<a href="https://i.stack.imgur.com/NhGtg.jpg" rel="nofollow noreferrer">2</a> = 3 in this output.
  but it's wrong. it must be; 1.
  gcd of 3 and 2 should be 1. not 3.</p>
  
  <p>I tried many ways. but I didn't solve this question. </p>
  
  <hr>
  
  <p>For Primusa,
  Your code is correct but in my university, we haven't see yet functions.
  su I can't use functions.</p>
  
  <p>so this is correct code that yours,</p>
  
  <pre><code>for i in range(n):
      for j in range(n):
          GCD = gcd(i, j)
          if GCD == 1:
              stdio.write("* ")
          else:
              stdio.write(" ")
      stdio.writeln()
  </code></pre>
  
  <p>and I tried to change that code without function. but doesn't work.
  my code,</p>
  
  <pre><code>for x in range(n):
      for y in range(n):
          while y != 0:
              temp = y
              y = x % y
              x = temp
          GCD = x
          if GCD == 1:
              stdio.write("* ")
          else:
              stdio.write(" ")
      stdio.writeln()
  </code></pre>
  
  <p>your output,
  <a href="https://i.stack.imgur.com/HHx97.jpg" rel="nofollow noreferrer">Your code</a>
  my output,
  <a href="https://i.stack.imgur.com/NhGtg.jpg" rel="nofollow noreferrer">my code</a>
  but my code is wrong. how my code's output will be like yours?</p>
  
  <p>normally my euclid's method workes right. but when I use that code in for nesting it won't work. </p>