#include <stdio.h> #define N 100 int foo(int n) { int sum = 0; if(n == 2) sum += 2; else sum = foo(n - 2) + n; return sum; } int main(void) { int n = N; printf("SUM = %d\n", foo(n)); return 0; }
#include <stdio.h> #define N 100 int main(void) { int i = N/2, sum = 0; for(; i>0; i--) { sum += 2*i; } printf("SUM = %d\n", sum); return 0; }