The Extended Euclidean Algorithm: Examples 1 and 2 (2pp.)

68 downloads 55 Views 67KB Size Report
The Extended Euclidean Algorithm. Example 1: m = 65,n = 40. Step 1: The (usual ) Euclidean algorithm: (1). 65 = 1 · 40 + 25. (2). 40 = 1 · 25 + 15. (3). 25 = 1 · 15 ...
The Number of Digits Recall: a computer stores and works with numbers in their binary form, i.e., to the base 2. More generally: Given any base b ∈ N, b ≥ 2, we can write a given natural number n ∈ N in the form (1)

n = dk−1bk−1 + . . . + d1b + b0,

with dk−1 6= 0 and 0 ≤ di < b, for all 0 ≤ i < k. We then write n = (dk−1, . . . , d0)b, and call this the representation of n to the base b. Remark: We observe that n satisfies the inequalities (2)

bk−1 ≤ n ≤ bk ,

which uniquely determine k = #digitsb(n), the number of digits of n to the base b. Explictly:   log(n) (3) k = [logb(n)] + 1 = + 1, log(b) where [x] = floor(x) denotes the greatest integer n ≤ x. Thus: #digitsb(n) = O(log(n)), if n ≥ 2.