I am always stuck at typecasting issues but now this case i did right but still getting errors,anyone help me with this clearly whats wrong here and explain me concept clearly so that i get clarfied
int nthTermOfGP(int N, int A, int R) {
` `if(N==1)
{
return A;
}
` `if(N<=0)
{
return 1;
}
long long mod = 1000000007;
long long ans = nthTermOfGP( N-1, A, R) % mod;
long long x=(R*ans)%mod;
return (int) x;
}
To find nth term of geometric progression ,i did simply that nth term is obtained by multipliying R
to n-1th term also in question they mentioned to return modulus of 10^9 +7 so i did but getting for some case getting theses run time errors.I am really unable to understand also i watcjed answer the casting is similar but whys mine worng
K Reddy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1