MATLAB: Error when calculating factorial

codeproblemcombiantionsfactorial

I want to calculate all the combinations for a X number of variables and I am doing this code:
m=6;%number of variables
TC=0;
for n=1:m,
C=factorial(m)/((factorial(n)*factorial(m-n));
TC=TC+C; %total number of combinations
end
TC
but I have the following error message from MATLAB:
Unbalanced or unexpected parenthesis or bracket.
Does anybody know which would be the right code to compute the total number of combinations, or where is the error in my code?

Best Answer

C=factorial(m)/((factorial(n)*factorial(m-n));
You are opening two parentheses, but closing only one in the denominator