title: Python program seems to run forever without outputting in terminal
body: <p>I have been working on a library to implement the RSA encryption method, and this file (along with others I have been working on) do not output, but instead after executing the script only output a blank line in terminal. I have run it through an autograder, and it times out. Below is the code for the library, but something tells me my issue could be an interpreter issue or something outside of the file itself. It looks like it could be getting stuck before reaching a return or output statement. I've also included a screenshot of the <a href="https://i.stack.imgur.com/GuIrb.png" rel="nofollow noreferrer">terminal output.</a></p>
  <pre><code>import stdio
  import stdrandom
  import sys
  
  
  # Generates and returns the public/private keys as a tuple (n, e, d). Prime numbers p and q
  # needed to generate the keys are picked from the interval [lo, hi).
  def keygen(lo, hi):
      primes = []
      for i in range(lo, hi):
          if _primes(0, i):
              primes += [i]
  
      ptemp = stdrandom.uniformInt(0, len(primes))
      qtemp = stdrandom.uniformInt(0, len(primes))
      p = primes[ptemp]
      q = primes[qtemp]
      n = p * q
      m = (p - 1) * (q - 1)
      while True:
          e = stdrandom.uniformInt(2, m)
          if e % m == 0 and m % e != 0:
              break
      d = 0
      for a in range(1, m):
          if (e * a) % m == 1:
              d = a
              break
      return n, e, d
  
  
  # Encrypts x (int) using the public key (n, e) and returns the encrypted value.
  def encrypt(x, n, e):
      return (x ** e) % n
  
  
  # Decrypts y (int) using the private key (n, d) and returns the decrypted value.
  def decrypt(y, n, d):
      return (y ** d) % n
  
  
  # Returns the least number of bits needed to represent n.
  def bitLength(n):
      return len(bin(n)) - 2
  
  
  # Returns the binary representation of n expressed in decimal, having the given width, and padded
  # with leading zeros.
  def dec2bin(n, width):
      return format(n, '0%db' % (width))
  
  
  # Returns the decimal representation of n expressed in binary.
  def bin2dec(n):
      return int(n, 2)
  
  
  # Returns a list of primes from the interval [lo, hi).
  def _primes(lo, hi):
      primes = []
      for p in range(lo, hi + 1):
          j = 2
          f = 1
          while(j * j &lt;= p):
              if(p % j == 0):
                  f = 0
                  break
              j = j + 1
          if(f == 1):
              primes += [p]
      return primes
  
  
  # Returns a list containing a random sample (without replacement) of k items from the list a.
  def _sample(a, k):
      b = a.copy()
      c = b[0:k]
      stdrandom.shuffle(c)
      return c
  
  
  # Returns a random item from the list a.
  def _choice(a):
      random = stdrandom.uniformInt(0, len(a))
      return random
  
  
  
  # Unit tests the library [DO NOT EDIT].
  def _main():
      x = ord(sys.argv[1])
      n, e, d = keygen(25, 100)
      encrypted = encrypt(x, n, e)
      stdio.writef('encrypt(%c) = %d\n', x, encrypted)
      decrypted = decrypt(encrypted, n, d)
      stdio.writef('decrypt(%d) = %c\n', encrypted, decrypted)
      width = bitLength(x)
      stdio.writef('bitLength(%d) = %d\n', x, width)
      xBinary = dec2bin(x, width)
      stdio.writef('dec2bin(%d) = %s\n', x, xBinary)
      stdio.writef('bin2dec(%s) = %d\n', xBinary, bin2dec(xBinary))
  
  
      if __name__ == '__main__':
          _main()
  </code></pre>