Your solution is correct but the only problem is that value of comb() and the factorial() function which have defined are exceeding the range of long integers for larger values. The solution is always within the range of long64 so if you try to do the divide and multiply efficiently without going out of the range you would get the solution excepted. So efficient way of doing it linearly would be somewhat like this : n C r can be found out by from n C 1 by multiplying (ni) and dividing by (i+1) and going iteratively till i = r1 starting from i = 1; answered 05 Feb '14, 19:51
