MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / sumN

Function sumN

Recursion/Code/sumFirstN.c:6–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <stdio.h>
5
6int sumN(int n){ //Base Case
7
8 if (n==1){
9 return 1;
10 }
11
12 else{
13 return n+sumN(n-1); // sumN(n-1) is recursive call
14 // and n + sumN(n-1) is our small calculation
15 }
16}
17
18int main(){
19

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected