I've been looking around trying to find a simple binomial coefficient algorithm, to no avail. The problem is the language I'm using for class is a bit... odd. A lot of it is using Yacc and Lex.
Anyways we did an example in class:
n=12; p=1; i=1;
while (i <= n) {
p = p * i;
print p;
i = i + 1;
};
This was an example of computing factorials, but now I need to modify it to be able to compute C(n,k) or N choose K (aka binomial coefficient), but I don't how complicated I should make it. We can choose any N and K (the user doesn't have to input them) so any random 2 numbers will work (such as the example above). I'm pretty sure this code only supports basic functions such as while loops and basic math, so I don't think using a factorial is possible... but I suppose I could use the above code as such?
Any ideas?