Math day question doubt

2 test cases are failing cant understand where is the fault

@rohit_1906
there is mistake in your code. In line 18, fastexp(a,n/2,p) is multiply only once, it should multiply twice. Substitute line 17 and 18 by
x = fastexp(a,n/2,p);
x = (xx)%p;
x=x
(a%p)%p;