22 lines
986 B
Plaintext
22 lines
986 B
Plaintext
;Task:
|
|
Implement the [[wp:Combination|combination]] <big> (<sup>n</sup>C<sub>k</sub>) </big> and [[wp:Permutation|permutation]] <big> (<sup>n</sup>P<sub>k</sub>) </big> operators in the target language:
|
|
|
|
:::* <math>^n\operatorname C_k =\binom nk = \frac{n(n-1)\ldots(n-k+1)}{k(k-1)\dots1} </math>
|
|
|
|
:::* <math>^n\operatorname P_k = n\cdot(n-1)\cdot(n-2)\cdots(n-k+1)</math>
|
|
|
|
<br>
|
|
See the Wikipedia articles for a more detailed description.
|
|
|
|
'''To test''', generate and print examples of:
|
|
* A sample of permutations from 1 to 12 and Combinations from 10 to 60 using exact Integer arithmetic.
|
|
* A sample of permutations from 5 to 15000 and Combinations from 100 to 1000 using approximate Floating point arithmetic.<br> This 'floating point' code could be implemented using an approximation, e.g., by calling the [[Gamma function]].
|
|
|
|
|
|
;Related task:
|
|
* [[Evaluate binomial coefficients]]
|
|
|
|
{{Template:Combinations and permutations}}
|
|
<br><br>
|
|
|