Skip to content

Instantly share code, notes, and snippets.

@Mjiig
Created April 8, 2012 21:55
Show Gist options
  • Save Mjiig/2340044 to your computer and use it in GitHub Desktop.
Save Mjiig/2340044 to your computer and use it in GitHub Desktop.
Project euler #53
#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