recursive works for n = 0..61 for all k educational purpose
| 309 | // works for n = 0..61 for all k |
| 310 | // educational purpose |
| 311 | uint64_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. |