Why do you feel you need to use loops? You should never write your own code for something that is far better computed using an existing code? (Remember, those who wrote nchoosek write code for a living, and they truly understand MATLAB as well as numerical methods.)
Anyway, what you are asking for is not a factorial, but a binomial coefficient. You could compute it as:
y = factorial(n)/factorial(n-m)/factorial(m);
y = prod([m+1 : n]) / prod([1 : n-m]);
Which is not surprisingly just
Anyway, the code you wrote DOES work. For example...
>> n = 12;
>> m = 7;
>> prod([m+1 : n]) / prod([1 : n-m])
It looks like what you wrote did work. They all agree, as they should.
Knowing why it did not work for you requires a crystal ball. When you have an error, you need to show us the complete error message. Show how you called the code. Just saying it did not work is meaningless, because in fact, what you wrote DOES work.