Quick description
A fact of fundamental importance in computational number theory is that calculating mod
can be done efficiently on a computer. The reason is simple: by repeatedly squaring
, one can work out
,
,
, ... and then other powers
can be calculated by taking products chosen according to the binary expansion of
.
Prerequisites
Modular arithmetic
Example 1
One example is enough to give the idea. Let us work out mod
. First, we repeatedly square
mod
until we have worked out
for every
such that
. We get
;
;
(because
);
;
. Next, we observe that
. Therefore,

Read full article from To work out powers mod n, use repeated squaring | Tricki
No comments:
Post a Comment