MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / rcombinations

Function rcombinations

libraries/statHelpers/statHelpers.cpp:300–305  ·  view source on GitHub ↗

recursive (mind your stack and time) works for n = 0..30 for all k educational purpose

Source from the content-addressed store, hash-verified

298// works for n = 0..30 for all k
299// educational purpose
300uint32_t rcombinations(uint16_t n, uint16_t k)
301{
302 if (k > (n-k)) k = n - k; // symmetry
303 if (k == 0) return 1;
304 return (n * rcombinations(n - 1, k - 1)) / k;
305}
306
307
308// recursive

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68