code: def nCk(n, k):
      
      if k > n:
          return 0
      if k == 0:
          return 1
  
      r = 1
      for d in range(1, k + 1):
          r *= n
          r /= d
          n -= 1
  
      return r
docs: http://blog.plover.com/math/choose.html