title: Hamming numbers in python
body: <p>I came across a question in codewars which asked to find the <em>n</em>th smallest Hamming Number. Basically the number can only have 2, 3, and/or 5 as factors.  Below is the code that I made for it.</p>
  <pre><code>def hamming(n):
      if n == 1:
          return 1
      elif n == 2:
          return 2
      elif n == 3:
          return 3
      elif n == 5:
          return 5
      else:
          count = 1
          i = 2
          while count &lt; n:
              if check(i):
                  count += 1
              i += 1
  
          return i
  
  def check(n):
      if n == 2:
          return True
      elif n == 3:
          return True
      elif n == 5:
          return True
      else:
          if n % 2 == 0:
              return check(n / 2)
          elif n % 3 == 0:
              return check(n / 3)
          elif n % 5 == 0:
              return check(n / 5)
          else:
              return False
  </code></pre>
  <p>But it's not giving the correct values.</p>