Progression Library 0.0.1
A header only arithmetic, geometric and fibonacci progression library
Loading...
Searching...
No Matches
ArithProgression Class Reference

Arithmetic progression: each term is obtained by adding a fixed increment. More...

#include <progression.hpp>

Inheritance diagram for ArithProgression:
Inheritance graph
Collaboration diagram for ArithProgression:
Collaboration graph

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)

Detailed Description

Arithmetic progression: each term is obtained by adding a fixed increment.

Example with increment = 3, first = 2: 2, 5, 8, 11, ...

Constructor & Destructor Documentation

◆ ArithProgression()

ArithProgression::ArithProgression ( long i = 1,
long f = 0 )

Constructs an arithmetic progression.

Parameters
iIncrement (default = 1)
fFirst value (default = 0)

Member Function Documentation

◆ next_value()

long ArithProgression::next_value ( )
overridevirtual

Returns the next term in the arithmetic progression.

Adds the fixed increment to the current value.

Returns
The next value.

Implements Progression.


The documentation for this class was generated from the following file: