I mention Grassmann algebras briefly here. I need to do some calculations in such algebras in this code for reasons described here. It is a puzzle how to represent them numerically. I think the answer is that I need only graded values. For a grade k value in a rank n Grassmann algebra I need C(n, k) reals. I suppose that sorting the subscripts of the basis elements is the best canonical ordering of these reals. I can define C thus:
int C(int n, int k){return k&&(k-n)? C(n-1, k-1)+C(n-1, k):1;}C(n, k) = n!/(k!(n-k)!)
suggests:
int C(int n, int k){return n>k?n*C(n-1, k)/(n-k):1;}or even
int f(int n){return n?n*f(n-1):1;} int C(int n, int k){return f(n)/(f(k)*f(n-k));}