/* Computes the Sum of numbers from 1 to N n sum 1 1 2 3 3 6 4 10 5 15 6 21 */ #include #include #define N 3 int sum(int n) { if(n == 1) //base case return 1; return n + sum(n-1); //recursive case } int main() { int x; x = sum(N); printf("sum of %d down to 1 is %d\n", N, x); system("pause"); }