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

Geometric progression: each term is obtained by multiplying by a fixed base. More...

#include <progression.hpp>

Inheritance diagram for GeometricProgression:
Inheritance graph
Collaboration diagram for GeometricProgression:
Collaboration graph

Public Member Functions

 GeometricProgression (long b=2)
 Constructs a geometric progression.
long next_value () override
 Returns the next term in the geometric 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 base
 Fixed multiplier applied at each step.
Protected Attributes inherited from Progression
long curr
 Current value in the progression.
long first
 First value of the progression.

Detailed Description

Geometric progression: each term is obtained by multiplying by a fixed base.

See also
FibonacciPg Example with base = 2, first = 1: 1, 2, 4, 8, ...

Constructor & Destructor Documentation

◆ GeometricProgression()

GeometricProgression::GeometricProgression ( long b = 2)

Constructs a geometric progression.

Geometric Progression.

The first term is always 1.

Parameters
bMultiplication factor (default = 2)

Member Function Documentation

◆ next_value()

long GeometricProgression::next_value ( )
overridevirtual

Returns the next term in the geometric progression.

Multiplies the current value by the fixed base.

Returns
The next value.

Implements Progression.


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