Revision- 9
What is Arithmetic Progression
Arithmetic Progression, also known as arithmetic sequence, is a sequence of numbers in which the difference between consecutive terms remains constant. This constant difference is called the common difference (d). Each term in the sequence can be obtained by adding the common difference to the previous term. The general form of an arithmetic progression is: a, a + d, a + 2d, a + 3d, ..., where 'a' is the first term and 'd' is the common difference.
Nth term in an AP can be calculated using
Formula : (a_n): a_n = a + (n-1)d
Keep on adding common difference(d) to the first term
Code
Following code is the implementation of the latter approach:
Sum of n terms in an AP can be calculated using
Formula: (S_n): S_n = (n/2)(2a + (n-1)d)
Keep on adding the current term to the sum
Code
Following code is the implementation of the latter approach:
Geometric Progression is a sequence of numbers in which the ratio between any two consecutive terms remains constant. This constant ratio is denoted by 'r' and defines the pattern and behavior of the progression. The terms in a geometric progression can be represented using the general formula: a_n = a_1 * (r^(n-1)), where 'a_n' represents the nth term, 'a_1' denotes the first term, 'n' represents the position of the term, and 'r' is the common ratio.
Nth term in an GP can be calculated using
1.Formula : a_n = a_1 * (r^(n-1))
2.Keep on multiplying common ratio(r) to the first term
Code
Following code is the implementation of the latter approach:
Sum of n terms in an GP can be calculated using
Formula: a_1 * ((r^n - 1) / (r - 1))
Keep on adding the current term to the sum
Code
Following code is the implementation of the latter approach: