This page uses the fast powering algorithm - a way of computing a large power of a number (modulo another number) in O(log n) time.
There are further optimisations, of course, such as using faster multiplication methods (such as 'Toom-cook') but these are hardly necessary.
^ (mod )