Given three integers A, B and N the task is to find N Arithmetic means between A and B. We basically need to insert N terms in an Arithmetic progression. where A and B are first and last terms.
Input : A = 20 B = 32 N = 5 Output : 22 24 26 28 30 The Arithmetic progression series as 20 22 24 26 28 30 32 Input : A = 5 B = 35 N = 5 Output : 10 15 20 25 30
Let A1, A2, A3, A4……An be N Arithmetic Means between two given numbers A and B . Then A, A1, A2 ….. An, B will be in Arithmetic Progression .
Now B = (N+2)th term of the Arithmetic progression .
Finding the (N+2)th term of the Arithmetic progression Series
where d is the Common Difference
B = A + (N + 2 – 1)d
B – A = (N + 1)d
So the Common Difference d is given by.
d = (B – A) / (N + 1)
So now we have the value of A and the value of the common difference(d),
now we can find all the N Arithmetic Means between A and B.
22 24 26 28 30
- Find N Geometric Means between A and B
- Find mean of subarray means in a given array
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Find the missing number in Arithmetic Progression
- Arithmetic Mean
- Arithmetic Number
- Arithmetic Progression
- How to sum two integers without using arithmetic operators in C/C++?
- Longest Arithmetic Progression | DP-35
- Subtract 1 without arithmetic operators
- Program for sum of arithmetic series
- Add two numbers without using arithmetic operators
- Sum of Arithmetic Geometric Sequence
- Program for class interval arithmetic mean
- Implement *, - and / operations using only + arithmetic operator
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.
Improved By : vt_m