On this excersice you will write a program that will implement 3 ways of doing a sumation.
- Iterative sumation
- Recursive sumation
- Direct sumation
All functionalities must be correctly aligned and documented (in code). As part of the documentation, the complexity of each of them must be included.
Function's name and definition
int interativeSum(int n)int recursiveSum(int n)int directSum(int n)
Work in the sum.cpp file
You must add each function's execution time measurement, make sure to report the result and the execution time in the following format:
# Iterative Sum with n = 3
- Result: 6
- Execution time: 0.0001 seconds
# Recursive Sum with n = 3
- Result: 6
- Execution time: 0.0701 secons
# Direct Sum with n = 3
- Result: 6
- Execution time: 0.041 secons
Compilation
make
Tests
make test