C Programming Code Examples C > Recursion Code Examples Find the Sum of Natural Numbers using Recursion Find the Sum of Natural Numbers using Recursion The positive numbers 1, 2, 3... are known as natural numbers. The program below takes a positive integer from the user and calculates the sum up to the given number. #include <stdio.h> int addNumbers(int n); int main() { int j; printf("Enter a positive integer: "); scanf("%d", &j); printf("Sum = %d",addNumbers(j)); return 0; } int addNumbers(int n) { if(n != 0) return n + addNumbers(n-1); else return n; }