This is my notepad where i collect the useful snippets of OpenSCAD code that i use over and over. Some better curated than others, some formatted for clarity some for efficiency.
Friday, June 2, 2017
n choose k
Find the number of ways one can select k items from a collection of nitems. Usage:
echo(choose(17,13));
function choose(n, k)=
k == 0? 1
: (n * choose(n - 1, k - 1)) / k;
No comments:
Post a Comment