C Programming Code Examples C > Recursion Code Examples C Program to calculate sum of numbers 1 to N using recursion C Program to calculate sum of numbers 1 to N using recursion #include<stdio.h> int calculateSum(int); int main() { int i, j; int result; printf("Input a number : "); scanf("%d", &j); result = calculateSum(j); printf("\nSum of Number From 1 to %d : %d", j, result); return (0); } int calculateSum(int j) { int res; if (j == 1) { return (1); } else { res = j + calculateSum(j - 1); } return (res); }