C Program to Find the Sum of Natural Numbers using Recursion
Recursive sum.
Sum = 55
Practice sums, factorials, Fibonacci, divisors, GCD/LCM, powers, primes, palindrome checks, and Armstrong numbers. Emphasis on efficient loops and numeric utilities.
Recursive sum.
Sum = 55
Sum 1..n.
Sum = 5050
Iterative factorial.
Factorial = 120
Table of a number.
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50
Generates first N numbers.
0 1 1 2 3 5 8 13 21 34
Euclidean algorithm.
GCD = 6
LCM via GCD.
LCM = 36
Counts decimal digits.
Digits = 5
Reverses digits.
Reverse = 4321
Computes base^exp.
Power = 1024
Checks if reversed equals original.
121 is palindrome
Trial division up to sqrt.
29 is prime
Lists primes in a range.
11 13 17 19 23 29 31 37 41 43 47
Sum of powered digits equals number.
153 is Armstrong
Lists Armstrong numbers.
153 370 371 407
Lists divisors.
1 2 4 7 14 28
Uses helper function.
11 13 17 19 23 29
Checks prime or Armstrong.
153 is Armstrong
Finds prime pair for N.
34 = 3 + 31
Recursive factorial.
Factorial = 720
Recursive gcd.
GCD = 6
Recursive exponent.
Power = 1024
gcc or clang. For example: gcc program.c -o program && ./program. On Windows, you may use MinGW or tdm-gcc; on macOS/Linux, the default package managers provide compilers.
C remains one of the most influential programming languages, powering operating systems, embedded devices, and performance-critical software. Practicing small, focused programs builds muscle memory and clarity with syntax and concepts such as data types, control flow, functions, arrays, pointers, and memory management.
On this page, you will find clean, well-formatted examples that compile across platforms. Each example includes a short description and expected output so you can quickly verify your understanding. Explore the topics via the sidebar and extend the code to experiment further.
Whether you’re preparing for interviews, working through coursework, or refreshing fundamentals, these examples offer a practical path to mastering C. Bookmark the page and return often to continue improving.