fork(191) download
  1. unsigned nChoosek( unsigned n, unsigned k )
  2. {
  3. if (k > n) return 0;
  4. if (k * 2 > n) /*return*/ k = n-k; //remove the commented section
  5. if (k == 0) return 1;
  6.  
  7. int result = n;
  8. for( int i = 2; i <= k; ++i ) {
  9. result *= (n-i+1);
  10. result /= i;
  11. }
  12. return result;
  13. }
  14.  
  15. #include <stdio.h>
  16.  
  17. int main(void)
  18. {
  19. printf("600 choose 3 is: %d\n", nChoosek(600, 3));
  20. return 0;
  21. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
600 choose 3 is: 35820200