honey-team / ufpy

Ufpy (Useful Python) - package for Python with some useful features
https://honey-team.github.io/ufpy-website
MIT License
3 stars 3 forks source link

Feature request: arithmetic and geometric progressions + fibonacci sequence #23

Open bleudev opened 5 months ago

bleudev commented 5 months ago

I request to add arithmetic and geometric progressions + fibonacci sequence classes in ufpy for simplifying working with they.

a = ArithmeticProgression(a1=0, a10=18)
a.d # 2
a.s(10) # S10 = 900
a.p(3) # a1 * a2 * a3 = 0

b = GeometricProgression(b1=1, q=2)
b(3) # b1 * q^(3-1) = 4
b.s(2) # S2 = 3
b.p(2) # a1 * a2 = 2

F = Fibonacci()
F(2) # 1
F(1:10) # [1, 1, 2, 3, 5, 8, 13, 31, 44, 75]
F.s(2) # 2
F.p(2) # 1