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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Harmonic Progression
- Summation of floor of harmonic progression
- Check whether nodes of Binary Tree form Arithmetic, Geometric or Harmonic Progression
- Program to find sum of harmonic series
- Program for harmonic mean of numbers
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Leibniz harmonic triangle
- Program to find the Nth Harmonic Number
- Sum of N-terms of geometric progression for larger values of N | Set 2 (Using recursion)
- Sum of elements of a Geometric Progression (GP) in a given range
- Find the missing number in Arithmetic Progression
- Removing a number from array to make it Geometric Progression
- Minimum De-arrangements present in array of AP (Arithmetic Progression)
- Program for N-th term of Geometric Progression series
- Program for N-th term of Arithmetic Progression series
- Program to print GP (Geometric Progression)
- Program to print Arithmetic Progression series
- Minimum number of operations to convert a given sequence into a Geometric Progression
- Longest arithmetic progression with the given common difference
- Ratio of mth and nth term in an Arithmetic Progression (AP)
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.