maths.series.geometric_series¶
This is a pure Python implementation of the Geometric Series algorithm https://en.wikipedia.org/wiki/Geometric_series Run the doctests with the following command: python3 -m doctest -v geometric_series.py or python -m doctest -v geometric_series.py For manual testing run: python3 geometric_series.py
Attributes¶
Functions¶
|
Pure Python implementation of Geometric Series algorithm |
Module Contents¶
- maths.series.geometric_series.geometric_series(nth_term: float, start_term_a: float, common_ratio_r: float) list[float] ¶
Pure Python implementation of Geometric Series algorithm
- Parameters:
nth_term – The last term (nth term of Geometric Series)
:param start_term_a : The first term of Geometric Series :param common_ratio_r : The common ratio between all the terms :return: The Geometric Series starting from first term a and multiple of common
ration with first term with increase in power till last term (nth term)
Examples: >>> geometric_series(4, 2, 2) [2, 4.0, 8.0, 16.0] >>> geometric_series(4.0, 2.0, 2.0) [2.0, 4.0, 8.0, 16.0] >>> geometric_series(4.1, 2.1, 2.1) [2.1, 4.41, 9.261000000000001, 19.448100000000004] >>> geometric_series(4, 2, -2) [2, -4.0, 8.0, -16.0] >>> geometric_series(4, -2, 2) [-2, -4.0, -8.0, -16.0] >>> geometric_series(-4, 2, 2) [] >>> geometric_series(0, 100, 500) [] >>> geometric_series(1, 1, 1) [1] >>> geometric_series(0, 0, 0) []
- maths.series.geometric_series.nth_term¶