SerSeries GP | Coding Problem

Input: A = 2, R = 2, N = 4
Output: 16
Explanation: The GP series is
2, 4, 8, 16, 32,... in which 16
is th 4th term.
problem solving
Input: A = 4, R = 3, N = 3
Output: 36
Explanation: The GP series is
4, 12, 36, 72,.. in which 36 is
the 3rd term.
/* author : @akash *//* 
c++ code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define ld long double
void solve()
{
int a;
int R;
cin>>a>>R;
int n;
cin>>n;
cout<<a*pow(R,n-1);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
solve();
cout<<"\n";
}
return 0;
}
// time complexity of this algorithm is : T(n)=O(LogN)

--

--

--

Student of Computer Science & Engineering at Moradabad Institute of Technology.

Love podcasts or audiobooks? Learn on the go with our new app.

WebdriverIO — Page Object advanced concepts

Let’s Learn C++ Builder IDE, RADS IDE

INTRODUCTION TO CLOUD COMPUTING

Introducing thin-edge.io!

Introduction to Web Programming

Solutions for Real-Time System by Jane W. S. Liu (Chapter 5)

Recap of the Month — April

Hello World

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akash Kumar

Akash Kumar

Student of Computer Science & Engineering at Moradabad Institute of Technology.

More from Medium

Stop the Insan-IT

Senior Year According to a Junior

How object and class attributes work ?

What exactly are software design patterns?