title: how to solve 3x+1 on python
body: <pre class="lang-py prettyprint-override"><code>    from random import randrange
  
      a = randrange(1, 9)
      print (a)
  
      if (a % 2) == 0:         
          y = a / 2        
      while True:     
          if (y % 2) == 0:      
              y = y / 2
              print (y)
          else: 
              b = (a * 3) + 1
      while True: 
          if (b % 2) == 0:
              b = b / 2
          else: 
              b = (a * 3) + 1   
          print (b)
  </code></pre>
  <p>&quot;I want to make a math problem solver in python that can find a random number</p>
  <p>between 1 and 9. Then if it is odd so it multiply it with 3 and add 1 in it and if it</p>
  <p>is even so it divide it by two and this process keep repeating. For example a number</p>
  <p>computer choose is 7 so :<br />
  <code>7*3 + 1 = 22</code><br />
  <code>22/2 = 11</code><br />
  <code>11*3 = 33</code><br />
  and so on.<br />
  It shouldn't stop until the answer is 0.Here is my code in which I tried but not sure where should I make it right?&quot;</p>