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.

Developing a public Terraform provider

Fleet Management Software: Modules, Functions, Advantages

Kotlin — Installation & Setup

GSoC 2020: the first milestone

Announcing Early Access For Tardigrade

Maximum product of k numbers in an array

Javascript “The prodigal son returns”

GITHUB Forked…. a Linux story

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

4 Tips for Training Frontline Workers

If LINUX is one then, what are Ubuntu, Mint and Fedora?

Timed Automata and Application

How to learn programming