How to calculate value of nCr ?

I was doing MARBLES https://www.codechef.com/problems/MARBLES question but I got stuck and dont know how to calculate the value of nCr ? Which method/concept to be used?

Have a try the formula nCr = n! / r! * (n - r)!

nCr can be calculated by direct formula or you can use some optimization.

We know that nCr = nC(n-r) Hence choose min(r,n-r).

let value of nCr = 1

Then iterate i trough 1 to r and keep ans *= (n-i+1) and dividing in next step by i.

Go through the article below. Hope this helps.

Ok thanks…

//