1) Solution is in http://www.cs.rpi.edu/~moorthy/Courses/CSCI2300/Lab2015-2-Solutions/modexp.cc answer to 1.25 is 64 (another method 2^126 mod(127) = 1; if 2^(125) mod 127 is x, then 2x mod 127 =1 , which means 2x = 128, x = 64) 2) 2^2 =1 mod 3, So any even power of 2 is 1 2^2006 is an even number - Hence 2 ^(2^2015) mod 3 is 1 3)(optional) Answer is 7 to question 1.26 as 17^4 mod 10 = 1 5) Solution is in http://www.cs.rpi.edu/~moorthy/Courses/CSCI2300/Lab2015-2-Solutions/prime.cc Solution is in http://www.cs.rpi.edu/~moorthy/Courses/CSCI2300/Lab2015-2-Solutions/prime2.cc to generate all prime numbers less than a million (modexp uses long long in their arguments) 5) a b quot a mod b 17 11 1 6 11 6 1 5 6 5 1 1 5 1 5 0 1 0 1 = 1 - 0 = 1 - (5 - 5*1) = 6*1 - 5 = 6* (6- 1*5) - 5 = 6*6 -7*5 = 6*6 - 7* (11-1*6)=13*6-7*11 = 13*(17-1*11) - 7*11 = 13*17 -20*11 Answer 1 = 13*17-20*11 x= 13, y = -20 6) Solution is in http://www.cs.rpi.edu/~moorthy/Courses/CSCI2300/Lab2015-2-Solutions/rk.cc