Given two numbers, first calculate arithmetic mean and geometric mean of these two numbers. Using the arithmetic mean and geometric mean so calculated, find the harmonic mean between the two numbers.
Input : a = 2 b = 4 Output : 2.666 Input : a = 5 b = 15 Output : 7.500
Arithmetic Mean: Arithmetic Mean ‘AM’ between two numbers a and b is such a number that AM-a = b-AM. Thus, if we are given these two numbers, the arithmetic mean AM = 1/2(a+b)
Geometric Mean: Geometric Mean ‘GM’ between two numbers a and b is such a number that GM/a = b/GM. Thus, if we are given these two numbers, the geometric mean GM = sqrt(a*b)
Harmonic Mean: Harmonic Mean ‘HM’ between two numbers a and b is such a number that 1/HM – 1/a = 1/b – 1/HM. Thus, if we are given these two numbers, the harmonic mean HM = 2ab/a+b
Now, we also know that
Harmonic Mean between 5 and 15 is 7.500
- Sum of Arithmetic Geometric Sequence
- Program to find the Nth Harmonic Number
- Program to find sum of harmonic series
- Find N Geometric Means between A and B
- Find N Arithmetic Means between A and B
- Find the missing number in Arithmetic Progression
- Harmonic progression Sum
- Harmonic Progression
- Leibniz harmonic triangle
- Program for harmonic mean of numbers
- Summation of floor of harmonic progression
- Geometric mean (Two Methods)
- Geometric Progression
- Program for sum of geometric series
- Program to print GP (Geometric Progression)
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.