sum generator

 #include <stdio.h>

#include <math.h>


int sum_till(int n){

    if (n<=0){

        return 0;

    }

    return (n+sum_till(n-1));

}


    




int main() {

    int  n , f ,i ; 

    printf("Enter  number till where you need : ");

    scanf("%d",&n);

    

    for (i=0 ; i <=n ; i++){

        f=sum_till(i);

        printf(" %d\n", f );

        

    }

    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings