Given the first element of the progression ‘a’, common difference between the element ‘d’ and number of terms in the progression ‘n’, where . The task is to generate harmonic progression using the above set of information.
Input : a = 12, d = 12, n = 5 Output : Harmonic Progression : 1/12 1/24 1/36 1/48 1/60 Sum of the generated harmonic progression : 0.19 Sum of the generated harmonic progression using approximation :0.19
Arithmetic Progression : In an arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant.
Harmonic Progression: A harmonic progression (or harmonic sequence) is a progression formed by taking the reciprocals of an arithmetic progression.
Now, we need to generate this harmonic progression. We even have to calculate the sum of the generated sequence.
1. Generating of HP or 1/AP is a simple task. The Nth term in an AP = a + (n-1)d. Using this formula, we can easily generate the sequence.
2. Calculating the sum of this progression or sequence can be a time taking task. We can either iterate while generating this sequence or we could use some approximations and come up with a formula which would give us a value accurate up to some decimal places. Below is an approximate formula.
Sum = 1/d (ln(2a + (2n – 1)d) / (2a – d))
Please refer brilliant.org for details of above formula.
Below is implementation of above formula.
Harmonic Progression : 1/12 1/24 1/36 1/48 1/60 Sum of the generated harmonic progression : 0.19 Sum of the generated harmonic progression using approximation :0.19
- Harmonic Progression
- Summation of floor of harmonic progression
- Leibniz harmonic triangle
- Program for harmonic mean of numbers
- Program to find the Nth Harmonic Number
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Program to find sum of harmonic series
- Arithmetic Progression
- Geometric Progression
- Program to print GP (Geometric Progression)
- Ratio of mth and nth term in an Arithmetic Progression (AP)
- Program to print Arithmetic Progression series
- Number of GP (Geometric Progression) subsequences of size 3
- Program for N-th term of Geometric Progression series
- Program for N-th term of Arithmetic Progression series
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.