So I've got a home task to write a recursive function searching for Binomial coefficient. My answer does not pass the time test. How can I improve it?
Code is here:
int newton ( int N, int K ){
if ( N < K )
return 0;
if ( N > 33 || K > 33 )
return -1;
if ( N == K || K == 0 )
return 1;
if ( K > N / 2 )
K = N - K;
return ( newton ( N - 1, K - 1 ) + newton ( N - 1, K ) );
}