:1→M
:While int(K
:.5K→K
:If int(2fPart(Ans
:AM-Pint(AM/P→M
:A²-Pint(A²/P→A
:End
I feel like it could be optimised in BASIC. And maybe use only three variables (base, exponent, mod).{.5K,A,1
While int(2Ans(1
Ans{.5,Ans(2),1+(Ans(2)-1)int(2fPart(Ans(1
Ans-Pint({0,1,1}Ans/P
End
Ans(3
Slower time but half the size:1→M
While iPart(K
.5K→K
If int(2fPart(Ans
PfPart(AM/P→M
PfPart(A2/P→A
End
1
For(I,1,K
PfPart(AAns/P
End
round(Ans,0