bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

luc050.c (744B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 08 Feb 2026
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a recursive function to obtain the sum of first 25 natural numbers.
      9 */
     10 /* Let Us C, Chap- 10 (Recursive), Qn No.: B(b) */
     11 /* This file is auto-generated by a bot. */
     12 /* This code is not compiled; it is for reference only. */
     13 
     14 
     15 #include <stdio.h>
     16 #include <math.h>
     17 #include <stdlib.h>
     18 
     19 int get_sum(int);
     20 
     21 int main()
     22 {
     23     int n = 25, sum;
     24 
     25     sum = get_sum(n);
     26     printf("Sum of first %d natural numbers is: %d\n", n, sum);
     27 
     28     return 0;
     29 }
     30 
     31 int get_sum(int n)
     32 {
     33     if (n == 0)
     34         return 0;
     35     else
     36         return n + get_sum(n - 1);
     37 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror