The example follows the algorithm for computing $M^e$ (mod $n$) described at the bottom of page 8 of the paper. Here's an implementation in Python:
def binary(e):
bits = []
while e > 0:
b = e % 2
bits.append(b)
e = e >> 1
bits.reverse()
return bits
def pow(M, e, n):
bits = binary(e)
print "Step 1: Binary representation of %d is %r" % (e, bits)
C = 1
strC = "1"
print "Step 2: C = %s" % (strC)
for e_i in bits:
C = (C * C) % n
strC = "(%s)^2" % strC
print "Step 3a: C = %d = %s mod %d" % (C, strC, n)
print "Step 3b: e_i = %d" % e_i,
if e_i == 1:
C = (C * M) % n
strC = "%s x %s" % (strC, M)
print "so C = %d = %s mod %d" % (C, strC, n)
else:
print "so don't change C"
pow(920, 17, 2773)
with output:
Step 1: Binary representation of 17 is [1, 0, 0, 0, 1]
Step 2: C = 1
Step 3a: C = 1 = (1)^2 mod 2773
Step 3b: e_i = 1 so C = 920 = (1)^2 x 920 mod 2773
Step 3a: C = 635 = ((1)^2 x 920)^2 mod 2773
Step 3b: e_i = 0 so don't change C
Step 3a: C = 1140 = (((1)^2 x 920)^2)^2 mod 2773
Step 3b: e_i = 0 so don't change C
Step 3a: C = 1836 = ((((1)^2 x 920)^2)^2)^2 mod 2773
Step 3b: e_i = 0 so don't change C
Step 3a: C = 1701 = (((((1)^2 x 920)^2)^2)^2)^2 mod 2773
Step 3b: e_i = 1 so C = 948 = (((((1)^2 x 920)^2)^2)^2)^2 x 920 mod 2773