In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 2nd
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #04 exercise sheet]
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
In mathematics, a combination is a selection of items from a set that has distinct members, such that the order of selection does not matter. If the set has n elements, the number of combinations of size k is denoted by \( C_{n,k} \) and can be computed as follows:
\[
C_{n,k} = \frac{n!}{k!(n - k)!}
\]
Can you help calculate the number of combinations?
Write a function combination(n, k) that, given two integers n and k, returns \( C_{n,k} \). Note that if \(k > n \), then \( C_{n,k} \) should return the string "NA"
(Not Applicable).
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ n ≤ 100 | The values of n and k |
Example Function Calls | Example Output |
print(combination(6, 2)) print(combination(15, 9)) print(combination(100, 4)) print(combination(3, 9)) |
15 5005 3921225 NA |