if it is given tha final answer fits in 64 bit signed integer then

we can run a loop for i  = n-r+1 to n
keeping result in a 64 bit signed integer
each time multiplying with i

in this loop we need to add some code that will divide the result with r!
to do this initialize a int j to 1
and each iteration check if the ans is divisible by j
keep dividing utill j divides ans or j = r+1

that will look like O(r^2) but we will be dividing with only r values so it
will be O(2*r) = O(r)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to