Given two values ‘m’ and ‘n’ and the 5th term of an arithmetic progression is zero. The task is to find the ratio of mth and nth term of this AP.
Input: m = 10, n = 20 Output: 1/3 Input: m = 10, n = 15 Output: 1/2
Approach: Acc. to the statement, 5th term is zero. Now understand the concept with an example. As A5=a+4*d=0.
Now, we have to find ratio of m = 10th term and n = 20th term.
= A + 9 * d
= A5 + 5 * d
= 0 + 5 * d
= 5 * d
= A + 19 * d
= A5 + 15 * d
= 0 + 15 * d
= 15 * d
Now, we have to find ratio, so Ans= A / A
Below is the required implementation:
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.
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Nth term where K+1th term is product of Kth term with difference of max and min digit of Kth term
- Minimize Nth term of an Arithmetic progression (AP)
- Find Pth term of a GP if Mth and Nth terms are given
- Arithmetic Progression containing X and Y with least possible first term
- Program for N-th term of Arithmetic Progression series
- Sum of P terms of an AP if Mth and Nth terms are given
- Mth bit in Nth binary string from a sequence generated by the given operations
- Find Nth term of the series where each term differs by 6 and 2 alternately
- Nth term of a sequence formed by sum of current term with product of its largest and smallest digit
- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- Nth term of given recurrence relation having each term equal to the product of previous K terms
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Find the number which when added to the given ratio a : b, the ratio changes to c : d
- Longest string in non-decreasing order of ASCII code and in arithmetic progression
- Program for N-th term of Geometric Progression series
- Longest Arithmetic Progression | DP-35
- Find the missing number in Arithmetic Progression
- Check whether Arithmetic Progression can be formed from the given array
- Count of AP (Arithmetic Progression) Subsequences in an array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.