Mark Dickinson: > def choose(n, k): > ntok = 1 > for t in xrange(min(k, n-k)): > ntok = ntok*(n-t)//(t+1) > return ntok
With few tests, it seems this is faster than the version by Jussi only with quite big n,k. (Another test to be added, is the assert n>0 of my original version (testing that n,k seem useful too)). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list