Evaluate binomial coefficients: Difference between revisions
Content added Content deleted
(→{{header|Python}}: Added a second (Python 3 compatible) functional version) |
(→Functional Python: Added tests for k=0 to k=5 (where n = 5)) |
||
Line 1,926: | Line 1,926: | ||
# |
# TESTS --------------------------------------------------- |
||
print( |
print( |
||
binomialCoefficient(5)(3) |
binomialCoefficient(5)(3) |
||
) |
|||
# k=0 to k=5, where n=5 |
|||
print( |
|||
list(map( |
|||
binomialCoefficient(5), |
|||
enumFromTo(0)(5) |
|||
)) |
|||
)</lang> |
)</lang> |
||
{{Out}} |
|||
<pre>10 |
|||
[1, 5, 10, 10, 5, 1]</pre> |
|||
=={{header|R}}== |
=={{header|R}}== |