What is wrong in this Math Day problem code

Hello kindly let me know why this code is failing 4 test cases in Math Day question

Link to code -

Hey @rahul31
Your code fails on cases where n = 1 as you aren’t performing modulation of a with p when printing.
So just make that cout statement as cout<<(a%p)<<"\n"; and your could should work just fine.

Hope it helps.

Got it as every test case has n==1 in it this is why my code was failing on 4 test cases.
Thank you so much.