Combination Function Help

kjakupak at gmail.com kjakupak at gmail.com
Wed Feb 12 23:59:58 CET 2014


def choices(n, k):
    if k == 1:
        return n
    if n == k:
        return 1
    if k == 0:
        return 1
    return choices(n - 1, k) + choices(n - 1, k - 1)

comb = choices(n, k)
print comb

print ("Total number of ways of choosing %d out of %d courses: " % (n, k))
n = int(input("Number of courses you like: "))
k = int(input("Number of courses you can register for: "))

Still isn't working though..



More information about the Python-list mailing list