Python Program to print Harmonic progress series

Python Program to print Harmonic progress series



In this, we discuss the HP series with example and also discuss how to print Harmonic series in Python Programming. First of all we learn about the definition of HP.

Harmonic progress

This program is used to find the sum of the harmonic progress sequences. Here H.P means harmonic progression. Harmonic progress is progress made by taking the interrelationships of arithmetic progress.

Example:
The sequence of numbers is called harmonic progression if the terms are reciprocal of the AP. Simply put, 1 / a, 1 / b, 1 / c, 1 / d, 1 / e, 1 / f are in AP while a, b, c, d, e, f are in HP. For example, 1 / a, 1 / (a   + d), 1 / (a   + 2d) and so on are in HP because a, a + d, a + 2d are in AP.


The harmonic series is the inverse of arithmetic progress. In general, words in harmonic progression can be referred to as 1 / a, 1 / (a   + d), 1 / (a   + 2d), 1 / (a   + 3d). 1 / (a   + nd).
The N term of AP is given as (a + (n - 1) d). 

Therefore, the nth term of harmonic progression is an interaction of the nth term of AP, which is 1 / (a   + (n - 1) d), where "a" is the 1st term of AP and "d" is a common difference.

If you are new to Programming then i will suggest you to learn first some basic of the Python Programming. If you already know programming then you can skip these steps.

let's take a look at the code how to print the Harmonic series in Python Programming
Python Code:
a = int(input('enter first term'))
d = int(input('enter common difference'))
n = int(input('enter number of terms'))
print('AP series as follows')
m = 1s = str(1)+'%'+str(n)
while(m<=n):
    r = a + (m-1)*d
    s = str(1)+'%'+str(r)
    print(s)
    m = m+1
Output:
enter first term 1
enter common difference 2
enter number of terms 9
AP series as follows
1%1
1%3
1%5
1%7
1%9
1%11
1%13
1%15

1%17