Created
April 8, 2012 21:55
-
-
Save Mjiig/2340044 to your computer and use it in GitHub Desktop.
Project euler #53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
double bang(int i) | |
{ | |
return i==0?1:(double) i * bang(i-1); | |
} | |
double ncr(int n, int r) | |
{ | |
double numerator=bang(n); | |
double denominator=bang(r)* bang(n-r); | |
return numerator/denominator; | |
} | |
int main ( void ) | |
{ | |
int n; | |
int r; | |
int count=0; | |
for(n=20;n<=100;n++) | |
{ | |
for(r=0;r<=n;r++) | |
{ | |
if(ncr(n, r) >1000000L) | |
count++; | |
} | |
} | |
printf("%d\n", count); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment