Python  1.0
Functions
_02a_Arithmetic_Progression Namespace Reference

Summing an Arithmetic Progression. More...

Functions

def S (n, a1, d)
 Calculates the sum of the first n terms of an Arithmetic Progression. More...
 
def Sp (n, a1, d)
 Calculates the sum of the first n terms of an Arithmetic Progression. More...
 
def main ()
 

Detailed Description

Summing an Arithmetic Progression.

An arithmetic progression or arithmetic sequence is a sequence of numbers such that the difference of any two successive members of the sequence is a constant.

For instance, the sequence 3, 5, 7, 9, 11, 13... is an arithmetic progression with common difference d=2, and first element a1=3.

Author
Paulo Roma
Since
08/04/2007
See also
http://en.wikipedia.org/wiki/Arithmetic_series

Function Documentation

◆ main()

def _02a_Arithmetic_Progression.main ( )

◆ S()

def _02a_Arithmetic_Progression.S (   n,
  a1,
  d 
)

Calculates the sum of the first n terms of an Arithmetic Progression.

Parameters
nan index of a term of the progression.
a1first term of the sequence.
ddifference between to consecutive terms.
Returns
sum of the first n terms: \(S(n,a_{1},r) = \frac{n}{2}(2a_{1} + (n-1)d).\)

Referenced by main().

◆ Sp()

def _02a_Arithmetic_Progression.Sp (   n,
  a1,
  d 
)

Calculates the sum of the first n terms of an Arithmetic Progression.

Parameters
nan index of a term of the progression.
a1first term of the sequence.
ddifference between to consecutive terms.
Returns
a string with all terms of the progression, until \(a_n\), separated by "+" and "=" to its sum: "1 + 4 + 7 + 10 + 13 + 16 + 19 = 70".

Referenced by main().