MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / sum

Function sum

Lab_07/sum.cpp:5–11  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5long long int sum(long long int n)
6{ // fuction called 'sum' foe calculating the sum of the natural numbers
7 if (n == 0)
8 return 0; // will return '0' when number will come to 0
9 else
10 return n + sum(n - 1); // using recursion
11}
12
13int main2()
14{

Callers 1

main2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected