
Asked in Wipro
Nth Term of Geometric Progression Problem
Given the first term A
, the common ratio R
, and an integer N
, your task is to find the Nth term of a geometric progression (GP) series.
Explanation:
The general form of a GP series is: A, A*R, A*R^2, A*R^3, ...
where A
is the first term and R
is the common ratio.
Input:
The first line contains an integer T
representing the number of queries or test cases. Each test case consists of a single line containing three space-separated integers: N
, A
, and R
.
Output:
For each test case, return an integer denoting the Nth term of the GP series modulo 10^9 + 7
.
Example:
Input:
3
4 2 3
5 1 2
6 5 2
Output:
54
16
160
Explanation:
For the first test case: N = 4, A = 2, R = 3
, the 4th term is 2*3^3 = 54
.
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 10^8
0 ≤ A ≤ 50
0 ≤ R ≤ 100
- Time limit: 1 second
Note:
The result should be calculated modulo 10^9 + 7
due to potential large values.

AnswerBot
4mo
Calculate the Nth term of a geometric progression series modulo 10^9 + 7.
Use the formula A * R^(N-1) to find the Nth term of the GP series.
Remember to calculate the result modulo 10^9 + 7.
Handle multi...read more
Help your peers!
Add answer anonymously...
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Wipro Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

