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

Function rcombinations64

libraries/statHelpers/statHelpers.cpp:311–316  ·  view source on GitHub ↗

recursive works for n = 0..61 for all k educational purpose

Source from the content-addressed store, hash-verified

309// works for n = 0..61 for all k
310// educational purpose
311uint64_t rcombinations64(uint16_t n, uint16_t k)
312{
313 if (k > (n-k)) k = n - k; // symmetry
314 if (k == 0) return 1;
315 return (n * rcombinations64(n - 1, k - 1)) / k;
316}
317
318
319// very slow double recursive way by means of Pascals triangle.

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68