Runtime Error on Math Day problem

Hi,

I am trying to solve Math Day problem.

But it fails on two test cases with Runtime Error.

Please check.

Thanks.

I simplified your code. Have a look

1 Like

Whao intuitive : (((((a^1)%p)^2)%p)^3)%p)^4%p)…)^n)%p

:clap::clap::clap:

Thanks.