101 friend std::ostream &operator<<(std::ostream &out,
189 for (
int i = 2; i <= n; ++i) {
190 std::cout << std::format(
" {} ",
next_value());
192 std::cout << std::endl;
196 out <<
"first value: " << apg.
first <<
" Current value: " << apg.
curr
197 <<
"increment by: " << apg.
inc <<
"\n";
216 sec_v = second_value;
Arithmetic progression: each term is obtained by adding a fixed increment.
Definition progression.hpp:83
long next_value() override
Returns the next term in the arithmetic progression.
Definition progression.hpp:182
long inc
Fixed increment added at each step.
Definition progression.hpp:105
ArithProgression(long i=1, long f=0)
Constructs an arithmetic progression.
Definition progression.hpp:171
long sec_v
second value
Definition progression.hpp:145
long next_value() override
Calculates the next value in the progression.
Definition progression.hpp:226
long first_value() override
sets the first value
Definition progression.hpp:220
FibonacciPg(long f=0, long s=1)
FibonacciPg constructor Takes two arguments first value and second value.
Definition progression.hpp:214
long prev
previous value
Definition progression.hpp:146
long next_value() override
Returns the next term in the geometric progression.
Definition progression.hpp:208
long base
Fixed multiplier applied at each step.
Definition progression.hpp:134
GeometricProgression(long b=2)
Constructs a geometric progression.
Definition progression.hpp:203
A header only c++ progression library.
Definition progression.hpp:40
virtual long first_value()
Resets the progression and returns the first value.
Definition progression.hpp:177
long first
First value of the progression.
Definition progression.hpp:73
virtual ~Progression()=default
Virtual destructor to allow proper cleanup of derived objects.
long curr
Current value in the progression.
Definition progression.hpp:72
virtual long next_value()=0
Advances to and returns the next value in the progression.
void print_progression(int n)
Prints the first n terms of the progression.
Definition progression.hpp:187