summaryrefslogtreecommitdiffstats
path: root/test/combinations.c
blob: cffdff1d4c6a5493a677cac26a1bd5dc5d0e4274 (plain)
1
2
3
4
5
6
7
8
9
10
11


void combinations(unsigned int n, unsigned *A) {
  unsigned int i, t = 1;
  A[0] = A[n] = 1;

  for (i = 1; i <= n/2; i++) {
    t = (t * (n+1-i)) / i;
    A[i] = A[n-i] = t;
  }
}