Skip to content

Instantly share code, notes, and snippets.

@pareshchouhan
Created August 6, 2014 17:41
Show Gist options
  • Select an option

  • Save pareshchouhan/fbb7326d88ba603fbf26 to your computer and use it in GitHub Desktop.

Select an option

Save pareshchouhan/fbb7326d88ba603fbf26 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
uint64_t fact(uint64_t n);
int main()
{
int t, n, r,i;
scanf("%d",&t);
for ( i =0 ; i < t ; i++) {
scanf("%d %d",&n,&r);
printf("%"PRIu64"\n",(uint64_t)(fact(n)/(fact(r) * fact(n-r))));
}
return 0;
}
uint64_t fact(uint64_t n) {
return (uint64_t)((n == 1 || n == 0) ? 1 : (n * fact(n-1)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment