Nov:05(Thu)
Please do exercises in teams of two. Doing so garners 5% extra credit.
Show intermediate steps/explanations for obtaining answers.
1001
1 0011
10 0000
101 1010
1100 1110
1111 1111
11 0101 0111
Try to do this without using a calculator.
exponentiation(a,e)
for the invocation exponentiation(3,11):
int exponentiation(int a, int e) { // a := , e :=
int result = 1; // result :=
int sqrrep = a; // sqrrep :=
while ( e > 0 ) { // ( > 0) :=
if ( e % 2 == 1 ) // ( % 2 == 1) := ( == 1) :=
result = result * sqrrep; // result := ( * ) :=
sqrrep = sqrrep * sqrrep; // sqrrep := ( * ) :=
e = e/2; // e := |_/2_| := |__| :=
}
while ( e > 0 ) { // ( > 0) :=
if ( e % 2 == 1 ) // ( % 2 == 1) := ( == 1) :=
result = result * sqrrep; // result := ( * ) :=
sqrrep = sqrrep * sqrrep; // sqrrep := * :=
e = e/2; // e := |_/2_| := |__| :=
}
while ( e > 0 ) { // ( > 0) :=
if ( e % 2 == 1 ) // ( % 2 == 1) := ( == 1) :=
result = result * sqrrep;
sqrrep = sqrrep * sqrrep; // sqrrep := ( * ) :=
e = e/2; // e := |_/2_| := |__| :=
}
while ( e > 0 ) { // ( > 0) :=
if ( e % 2 == 1 ) // ( % 2 == 1) := ( == 1) :=
result = result * sqrrep; // result := ( * ) :=
sqrrep = sqrrep * sqrrep; // sqrrep := ( * ) :=
e = e/2; // e := |_/2_| := |__| :=
}
while ( e > 0 ) { // ( > 0) :=
return result; // return
}
Show an 'algorithm trace' like that
for the invocation exponentiation(10,13).
(Feel free to simply copy the above material (HTML)
and change details such as what numbers are in the spaces.
If you do this, you might need to adjust the sizes of the spaces.)
modular_exponentiation(a,e,m)
for the
invocation modular_exponentiation(7,13,17).
Acknowledgement:
Some of the following exercises are derived from Richard Johnsonbaugh.
modular_exponentiation()
is the fact that
for any integers x and y,
and for any positive integer m,
(x*y) mod m == ((x mod m)*(y mod m)) mod m.
Similarly,
(x+y) mod m == ((x mod m)+(y mod m)) mod m
(for any integers x and y
and for any positive integer m).
f13(y) := ((y mod 7) + (|_(y-1)/4_| mod 7) - (|_(y-1)/100_| mod 7) + (|_(y-1)/400_| mod 7)) mod 7
Show all those intermediate values mod 7.
For example for next year, 2010:
f13(2010) := ((2010 mod 7) + (|_(2010-1)/4_| mod 7) - (|_(2010-1)/100_| mod 7) + (|_(2010-1)/400_| mod 7)) mod 7
:= ((2010 mod 7) + ( 502 mod 7) - ( 20 mod 7) + ( 5 mod 7)) mod 7
:= ( 1 + 5 - 6 + 5 ) mod 7
:= ( 5 ) mod 7
:= 5
For this exercise,
remember to
redo all of the calculations
of f13(y)
which you did previously,
i.e. for all of
the years specified previously.
if complete/thorough prime factorization of a isDetermine the greatest common divisor of each of the following pairs of integers (a,b), explicitly using the above scheme. In each case, you'll need to give the complete/thorough prime factorization of each number (a and b as well as gcd(a,b)).2e2 * 3e3 * 5e5 * 7e7 * ...
and complete/thorough prime factorization of b is2f2 * 3f3 * 5f5 * 7f7 * ...
thengcd(a,b) := 2min(e2,f2) * 3min(e3,f3) * 5min(e5,f5) * ...