- 1

Geometric progression

Given the second and third terms (-2.0 <=g2, g3 <= 2.0) of a GP, find the nth (1 <= n <= 100) term. The output should be a string representing the Inth term, rounded off to 3 decimal places. You are required to fill in a function which takes as input an integer 'n' and sets the output variable to the sum of divisors of 'n'. The output is to be guaranteed to fit in a 32-bit signed integer. Input Specification: input1: Second Term of GP (Double) input2: Third Term of GP (Double) input3: Total number of terms in the series (Int) Output Specification: Return a string representing the nth term, rounded off to 3 decimal places. Example 1: input1: 1 input2: 2 input3: 4 Output: 4.0 Explanation: g2= 1, g3 = 2, n = 4, r = 2, gn = g4 = 4 (r refers to the common ratio between adjacent terms in a geometric progression) Example 2: input1: 1 input2: 2 input3: 5 Output: 8.0 Explanation: g2= 1, g3 = 2, n = 5, r = 2, gng4 = 8 (r refers to the common ratio between adjacent terms in a geometric progression)

16th Apr 2021, 10:42 AM
Shaik Masthan
Shaik Masthan - avatar
2 Respuestas
0
5th Aug 2022, 3:06 PM
Yash Thakur
Yash Thakur - avatar
- 3
#include<stdio.h> #include<string.h> // Read only region start char* nthTerm(double input1, double input2, int input3) { // Read only region end // Write code here double r = input2/input1; double ans = a* (double) pow(r, (double) (input3-1)); double a input1/r; char result = new char[1000]; Results Your Testcase on ratio } This is my code can any find the error in that code
16th Apr 2021, 10:43 AM
Shaik Masthan
Shaik Masthan - avatar