Update residue_ntheory.py

simple patch to use optimized pow(a,x,n) for a**x % n, makes it MUCH faster for big numbers
Update residue_ntheory.py
Merge pull request #2371 from QuaBoo/patch-1

A simple pow() optimization