# Geometry and Discrete Mathematics (Proofs)

posted by
**Raj** on
.

Observe that the last two digits of 7^2 are 49, the last two digits of 7^3 are 43, the last two digits of 7^4 are 01, and the last two digits of 7^5 are 07. Prove that the last two digits of 7^201 are 07.

7^2 = ...49

7^3 = ...43

7^4 = ...01

7^5 = ...07

7^201 = ...07

Break 201 into a product of primes. Hint: 201 is divisible by 3.

Yes, but what would I do with 67 and 3?

You should use modular arithmetic. This works as follows. On the set of integers you define a so-called equivalence relation E which in this case is:

n1 E n2 if n1 - n2 = 100*k

where k is an integer. So, two integers are equivalent if they differ by a miltiple of 100.

We then use the notation [n] for the set of all integers that are related to n via the equivalence relation.

So, e.g. [3] = {....,-97,3,103,...}

There are then 100 such sets:

[0], [1], [2], ..., [99].

Note that [100] and [0] are the same sets.

On the set M = {[0],[1],...[99]} (the so-called quotient set) you can define addition and multiplication:

[n1] + [n2] = [n1 + n2]

[n1]*[n2] = [n1*n2]

Modular artithmetic is just doing calculations on the set M. You can write that [102] = [2] instead of saying that 102 is related to 2. Another notation is:

102 = 2 Mod(100)

Anyway, modular artithmetic (modulo 100 in tis case) allows you to calculate what you want. If we delete the square brackets (or the Mod symbol):

7^4 = 1

Raise both sides to the 50-th power

7^200 = 1

and then multiply by 7:

7^201 = 7

In the general case where you have to compute:

X^Y Mod N

and there are no obvious shortcuts, it is simplest to write down the binary representaton of Y:

Y = a_{r} 2^r + a_{r-1}2^(r-1) + ..

where the a_{r} are either 1 or zero.

This means that:

Y = 2^(r1) + 2^(r2) + ...

for some r1 > r2 > ...

You can then write:

X^Y = X^[2^(r1)]*X^[2^(r2)]

So, all you have to do is to raise X to the appropriate powers of two and then multiply these things together. Raising X to such powers can be done by repeatedly squaring X.

E.g. what is

2^(1133) Mod 41?

Expand 1133 in binary system. You can do that easily by subtracting 1 if you can't divide by 2 and then dividing by 2 repeatedly until the number becomes odd, subtracting 1 again and repeating the process:

1133 = 1 + 1132

1132 = 4*283

283 = 1 + 2*141

141 = 1 + 4*35

35 = 1 + 2*17

17 = 1 + 16

1133 = 1 + 4*(1 + 2*(1+4*(1+2*(1+16))))=

1 + 4 + 8 + 32 + 64 + 1024

Note that the powers of two you get in here are just the "cumulative" product of the factors of two you get when you work your way through reducing 1133 by repeatedly subtracting 1 and dividing by two.

You then calculate the powers:

2^1 = 2

2^4 = 16

2^8 = 16^2 = 10

2^16 = 10^2= 100 = 18

2^32 = 18^2 = 37

2^64 = 37^2 = (-4)^2 = 16

2^128 = 16^2 = 2^8 (already alculated)

2^(1024) = 2^64 = 16

So we obtain:

2^1133 = 2*16*10*37*16*16 = 33