wes d2a2ba9e15 first commit 4 rokov pred
..
README.md d2a2ba9e15 first commit 4 rokov pred
code.cpp d2a2ba9e15 first commit 4 rokov pred
unitTest.cpp d2a2ba9e15 first commit 4 rokov pred

README.md

Recursion: Sum

by Matt tags: recursion, math, numbers, language_fundamentals

Summary

Write a function that finds the sum of the first n natural numbers. Make your function recursive. Examples sum(5) ➞ 15 // 1 + 2 + 3 + 4 + 5 = 15 sum(1) ➞ 1 sum(12) ➞ 78 Notes Check the Resources tab for info on recursion.

Instructions

Write a function that finds the sum of the first n natural numbers. Make your function recursive.

Examples

sum(5) ➞ 15
// 1 + 2 + 3 + 4 + 5 = 15

sum(1) ➞ 1

sum(12) ➞ 78

Notes

Check the Resources tab for info on recursion.