Getting one test case failed

#include
using namespace std;

int get_power(int a,int b,int c,int result)
{
if(b==0)
return result;
result=result*(a*1)%c;
return get_power(a,b-1,c,result);
}

int main()
{
int a,b,c;
cin>>a>>b>>c;
int result=1;
int x=get_power(a,b,c,result);
cout<<x;
}

Hey Meghna, mention the problem’s name also.

modular exponentiation

Hey Meghna, check your code for this case
input:
56789 3452 100000

your code’s output:
82609

but the expected output is:
57521

I am not getting. What’s wrong in it?

i am not getting what’s wrong in it?

Hey Meghna, value of result is out of range if int for some point, So update your code like this

#include
using namespace std;

long long int get_power(int a,int b,int c,long long int result)
{
    if(b==0)
        return result%c;
    result=(result%c)*(a%c);
    return get_power(a,b-1,c,result);
}

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    long long int result=1;
    long long int x=get_power(a,b,c,result);
    cout<<x;
}

Hey Meghna, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required. And please mark your doubts as resolved in your course’s “Ask Doubt” section, when your doubt is resolved.