title: Solving three variables Diophantine equation in Python
body: <p>I'm a beginner in Python, and tried to take <a href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/" rel="nofollow">MIT 6.00</a>, the page provided is the assignments page. </p>
  
  <p>I'm at <a href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset2.pdf" rel="nofollow">assignment 2</a>, where i have to find a solution for Diophantine equation, i'm really not that great in math, so i tried to understand what it does as much as i can, and think of a solution for it. </p>
  
  <p>Here's what i got to :</p>
  
  <pre><code>def test(x):
      for a in range(1,150):
          for b in range(1,150):
              for c in range(1,150):
                  y = 6*a+9*b+20*c
                  if y == x:
                      print "this --&gt; " , a, b, c
                      break
                  else : ##this to see how close i was to the number
                      if y - x &lt; 3: 
                          print a, b, c , y
  </code></pre>
  
  <p>The assignment states that there's a solution for <code>50, 51, 52, 53, 54, and 55</code>, but unfortunately the script only gets the solution for <code>50, 53 and 55</code>.</p>
  
  <p>I'd be very grateful if someone explained what's wrong in my code, or if i'm not understanding Diophantine equation at all, please tell me what is it all about and how to find a solution for it, since i cant get the assignment's explanation into my head.</p>
  
  <p>Thanks.</p>