|
Progression Library 0.0.1
A header only arithmetic, geometric and fibonacci progression library
|
Arithmetic progression: each term is obtained by adding a fixed increment. More...
#include <progression.hpp>


Public Member Functions | |
| ArithProgression (long i=1, long f=0) | |
| Constructs an arithmetic progression. | |
| long | next_value () override |
| Returns the next term in the arithmetic progression. | |
| Public Member Functions inherited from Progression | |
| virtual long | first_value () |
| Resets the progression and returns the first value. | |
| void | print_progression (int n) |
| Prints the first n terms of the progression. | |
| virtual | ~Progression ()=default |
| Virtual destructor to allow proper cleanup of derived objects. | |
Protected Attributes | |
| long | inc |
| Fixed increment added at each step. | |
| Protected Attributes inherited from Progression | |
| long | curr |
| Current value in the progression. | |
| long | first |
| First value of the progression. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const ArithProgression &sdt) |
Arithmetic progression: each term is obtained by adding a fixed increment.
Example with increment = 3, first = 2: 2, 5, 8, 11, ...
| ArithProgression::ArithProgression | ( | long | i = 1, |
| long | f = 0 ) |
Constructs an arithmetic progression.
| i | Increment (default = 1) |
| f | First value (default = 0) |
|
overridevirtual |
Returns the next term in the arithmetic progression.
Adds the fixed increment to the current value.
Implements Progression.