This was posted by Ben Fritz, class of 2007:
Hey everyone. I'm not sure how helpful this will be this late in the quarter, but I wrote a power-mod function for the TI-89 calculator. 
I don't have an interface to the laptop (it's an old one), so I'll just post the code here 
(needs some modification because I don't have a "sto->" key on my laptop): 
pmod(base,pow,n) 
Func 
If pow=0 Return 1 
Local exps 
Local vals 
Local i 
Local ret {1}->exps {mod(base,n)}->vals 
While exps[i]exps[i+1] mod(vals[i]^2,n)->vals[i+1] i+1->i EndWhile 
1->ret 
While pow>0 
If pow>=exps[i] Then mod(vals[i]*ret,n)->ret pow-exps[i]->pow EndIf 
i-1->i 
EndWhile 
Return ret 
EndFunc 
Hope it is useful! If not, then maybe for future classes...