Donate SIGN UP

What Does This Mean???

Avatar Image
Goodsoulette | 15:46 Fri 28th Jun 2013 | Science
4 Answers
http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%5Cfrac%7Bn%7D%7Bk%7D%5Ctimes%5Cfrac%7Bn-1%7D%7Bk-1%7D%5Ctimes%5Ccdots%5Ctimes%5Cfrac%7Bn-k%2B2%7D%7B2%7D%5Ctimes%5Cfrac%7Bn-k%2B1%7D%7B1%7D%7D&bg=T&fg=000000&s=2


In really simple terms....."Write a function choose(n, k) which takes two integers n and k; we guarantee n>k>0. The function should return the value given in the formula above." I don't particularly understand the maths though :/ I mean what is going to be where the dots are.
Gravatar

Answers

1 to 4 of 4rss feed

Best Answer

No best answer has yet been selected by Goodsoulette. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
What you are given is a series of decreasing terms that have to be multiplied together (much like a factorial)

You start with the fraction n/k where n and k are integers and n>k

Each subsequent terms has the numerator and denominator decreased by 1 and the series continues until the denominator reaches 1.

Neatest solution would be to write a recursive function that calls itself with parameters (n-1), (k-1) until k=1.
well in psuedo code:
a=1
do until k < 2
a=a*(n/k)
k=k-1
end
answer is in a
or in a recursive function
function atot(k,n)
if k>2 then atot=(n/k)*atot(k-1,n-1) else atot=1
end
then answer=atot(k,n)
eg answer = atot(9,8)
for k=9 and n=8

"what is going to be where the dots are?"is that the dots indicate that the pattern continues but some terms are not shown.
So, for example, the first component is n/k as shown, the next is (n-1)/(k-1) as shown, the next (not shown) is (n-2)/(k-2), then it's (n-3)/(k-3). This continues until we get to the final component which is as shown

Replace n and k by numbers such as 6 and 4 to see what's happening. If n=6 and k = 4 the calculation will be:
(6/4) x (5/3) x (4/2) x (3/1)
Question Author
Thank you all for your help.

1 to 4 of 4rss feed

Do you know the answer?

What Does This Mean???

Answer Question >>