Definition of harmonic progression (A.P.):
This C Program calculates the the sum of H.P series. This program is used to find the sum of the harmonic progression series. Here H.P stands for harmonic progression. Harmonic progression is a progression formed by taking the reciprocals of an arithmetic progression.
Example of H.P. series:
1/3, 1/6, 1/9, …
If you take the reciprocal of each term from the above HP, the sequence will become
3, 6, 9, ...
which is an AP with a common difference of 3.
C Program
#include<stdio.h> #include<conio.h> void main() { int n; float i, sum, t; printf("1+1/2+1/3+......+1/n\n"); printf("Enter the value of n\n"); scanf("%d",& amp; n); sum=0; for (i=1;i<=n;i++) { t=1/i; sum=sum+t; } printf("%f",sum); getch(); }
Output:
1 + 1 / 2 + 1 / 3 +......+1 / n Enter the value of n 5 the Sum of H.P Series is = 2.283334