for example im trying to
find 7 644 mod 645 which answer should be 436
find 11 644 mod 645 which answer should be 1
find 3 2003 mod 99 which answer should be 27
find 123 1001 mod 101 which answer should be 22
the only one I have correct is the last one which is 22
here is what i have
def me(b, n, m): a = bin(n)[:1:-1] x = 1 power = int(B)/> % int(m) for i in range(len(a)): if a[i] == '1': x = (x * power) % m power = (power * power) % m return str(x) print (me(7, 644, 645)) print (me(11, 644, 645)) print (me(3, 2003, 99)) print (me(123, 1001, 101))
This post has been edited by stephanie904: 15 February 2013 - 04:52 PM