Hope this will work perfectly;

if(r > n-r)
r = n - r;
int result = n;
for(int i=2; i<=r; i++)
{
n--;
result *= n;
result /= i;
result %= p;
}
print result;

On Sat, Mar 3, 2012 at 9:42 PM, pankajsingh <[email protected]> wrote:

> @amrit- thnks!!
>
> --
> 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.
>

-- 
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