Combinations and permutations: Difference between revisions

Content added Content deleted
(Clarify task description. Promote from draft to full task status.)
Line 1: Line 1:
{{draft task|Probability and statistics}}{{draft task|Discrete math}}
{{task|Probability and statistics}}{{task|Discrete math}}
{{wikipedia|Combination}} {{wikipedia|Permutation}}
{{wikipedia|Combination}} {{wikipedia|Permutation}}

;Task:
Implement the [[wp:Combination|combination]] (<sup>n</sup>C<sub>k</sub>) and [[wp:Permutation|permutation]] (<sup>n</sup>P<sub>k</sub>) operators in the target language:
Implement the [[wp:Combination|combination]] (<sup>n</sup>C<sub>k</sub>) and [[wp:Permutation|permutation]] (<sup>n</sup>P<sub>k</sub>) 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 C_k =\binom nk = \frac{n(n-1)\ldots(n-k+1)}{k(k-1)\dots1} </math>
Line 6: Line 8:
See the wikipedia articles for a more detailed description.
See the wikipedia articles for a more detailed description.


To test, generate and print examples of:
'''To test''', generate and print examples of:
* Permutations from 1 to 12 and Combinations from 10 to 60 using exact Integer arithmetic.
* A sample of permutations from 1 to 12 and Combinations from 10 to 60 using exact Integer arithmetic.
* Permutations from 5 to 15000 and Combinations from 100 to 1000 using approximate Floating point 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]].
This 'floating point' code could be implemented using an approximation, e.g., by calling the [[Gamma function]].


'''See Also:'''
'''See Also:'''
* [[Evaluate binomial coefficients]]
* [[Evaluate binomial coefficients]]
{{Template:Combinations and permutations}}
{{Template:Combinations and permutations}}

=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{works with|ALGOL 68|Revision 1 - one minor extension to language used - PRAGMA READ, similar to C's #include directive.}}
{{works with|ALGOL 68|Revision 1 - one minor extension to language used - PRAGMA READ, similar to C's #include directive.}}