{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# problems07-sol - procedure slow mod b âˆ integer n m âˆ...

This preview shows page 1. Sign up to view the full content.

MATH S-104 Lecture 7 In-class Problem Solutions July 14, 2009 Problem 1 * : Prove that parts (i) and (ii) of Theorem 3.4.1 are true: (ii) if a b , then a bc for all integers c Since a b , there is some integer k such that b = ka . Thus bc = bka , so a bc . (iii) if a b and b c , then a c Since a b , b = ka . Since b c , c = mb . Thus, c = mka , so a c . Problem 2 : Below is a slow algorithm for doing modular exponentiation. Describe a modular exponentiation algorithm that has complexity O ( log n ) , where the exponent is represented as a binary expansion, as shown below. Algorithm 7.0:
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: procedure slow mod ( b âˆ¶ integer , n, m âˆ¶ positive integers) x âˆ¶ = 1 for i âˆ¶ = to n x âˆ¶ = x â‹… b mod m { x equals b n mod m } Â± Â² Â³ Â´ Algorithm 7.0: Fast modular exponentiation procedure fast mod ( b âˆ¶ integer , n = ( a k-1 a k-2 . . . a 1 a 2 ) 2 , m âˆ¶ positive integers) x âˆ¶ = 1 power âˆ¶ = b mod m for i âˆ¶ = to k-1 if a i = 1 then x âˆ¶ = ( x â‹… power ) mod m power âˆ¶ = ( power â‹… power ) mod m { x equals b n mod m } 1...
View Full Document

{[ snackBarMessage ]}