I checked and I think your conditions have problem. Check here:
int newton ( int N, int K ){
if ( N == K || K == 0 )
return 1;
return ( newton ( N - 1, K - 1 ) + newton ( N - 1, K ) );
}
I checked this function with newton(33,16) and it works without timeout. I think your other conditions cause some problem too.
In addition, memorization (some people may call it dynamic programming) can improve answer. Here is with memorization:
int newton_imp(int N, int K, int* mem, int size){
if ( N == K || K == 0 )
return 1;
if ( mem[(N-1)*size + K-1] == 0)
mem[(N-1)*size + K-1] = ( newton_imp(N - 1, K - 1, mem, size) + newton_imp(N - 1, K, mem, size) );
return mem[(N-1)*size + K-1];
}
int newton(int N, int K) {
int res = -1;
int* mem = calloc(N*K, sizeof(*mem));
if (mem) {
res = newton_imp(N, K, mem, K);
free(mem);
}
return res;
}