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

Fibonacci Progression: each term is the sum of the previous two terms. More...

#include <progression.hpp>

Inheritance diagram for FibonacciPg:
Inheritance graph
Collaboration diagram for FibonacciPg:
Collaboration graph

Public Member Functions

 FibonacciPg (long f=0, long s=1)
 FibonacciPg constructor Takes two arguments first value and second value.
long first_value () override
 sets the first value
long next_value () override
 Calculates the next value in the progression.
Public Member Functions inherited from Progression
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 sec_v
 second value
long prev
 previous value
Protected Attributes inherited from Progression
long curr
 Current value in the progression.
long first
 First value of the progression.

Detailed Description

Fibonacci Progression: each term is the sum of the previous two terms.

Note
Example; with first term 0 and second term 1; the next term is 0+1=1, ie 0,1,1,2,3,5,8,13,21,...

Constructor & Destructor Documentation

◆ FibonacciPg()

FibonacciPg::FibonacciPg ( long f = 0,
long s = 1 )

FibonacciPg constructor Takes two arguments first value and second value.

Fibonacci Progression.

Parameters
[in]ffirst value
[in]ssecond value Initialize f and s to 0 and 1 respectively
Here is the call graph for this function:

Member Function Documentation

◆ first_value()

long FibonacciPg::first_value ( )
overridevirtual

sets the first value

Returns
first value

Reimplemented from Progression.

Here is the caller graph for this function:

◆ next_value()

long FibonacciPg::next_value ( )
overridevirtual

Calculates the next value in the progression.

Returns
next value in fibonacci progression

Implements Progression.


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