Here is how to calculate combinations :
You shouldnt have used the ! symbol in your example because it means factorial. For example, 5! = 1*2*3*4*5 = 120
Now onto the main topic, the formula that will calculate C(b - a) is b! / (a! * (b-a)!). For example, C(49, 6) = 49! / (6! * 43!)
Action script :
code:
function fact (a : Number) {
return (a <= 0 ? 1 : a * fact (a - 1)); //It makes no sense for a to be < 0 but returning 1 is better than an infinite loop.
}
function combinations (a : Number, b : Number) {
return (fact(b)) / (fact(a) * fact(b-a));
}