[email protected] Wrote in message:
> 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 c
On 12/02/2014 22:59, [email protected] 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)
comb = choices(n, k)
print comb
print ("Total number of ways of choosing
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
[email protected] Wrote in message:
> 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)
> print ("Total number of ways of choosing %d out of %d courses: " % (n,
On 12/02/2014 15:56, [email protected] 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)
print ("Total number of ways of choosing %d out of %d courses: " % (n,
On Wednesday, February 12, 2014 7:56:05 AM UTC-8, [email protected] wrote:
[snip]
> choices(n, k)
>
> Changed it like you said, didn't work
What are you doing with the value returned by the function, choices()? Right
now, you aren't doing anything with it. You are throwing it away. That's the
Y
On Feb 12, 2014 11:00 AM, 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 o
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)
print ("Total number of ways of choosing %d out of %d courses: " % (n, k))
n = int(input("Number of courses you like: "))
k =
On 12/02/2014 15:20, [email protected] wrote:
So I need to write a function based off of nCr, which I have here:
def choices(n, k):
if n == k:
return 1
if k == 1:
return n
if k == 0:
return 1
return choices(n - 1, k) + choices(n - 1, k - 1)
It wor