Combination Function Help
Joel Goldstick
joel.goldstick at gmail.com
Wed Feb 12 11:21:26 EST 2014
Y
On Feb 12, 2014 11:00 AM, <kjakupak at gmail.com> wrote:
>
> 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)
Following line never runs
> 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: "))
> choices(n, k)
>
> Changed it like you said, didn't work
> --
> https://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140212/5b96b645/attachment.html>
More information about the Python-list
mailing list