L05_exgcd_print

# L05_exgcd_print - = 99 j = 63 1 First run the regular GCD...

This preview shows pages 1–2. Sign up to view the full content.

1 i k [ i ] = j [ i ] q [ i ] + r [ i ] k [ i ] j [ i ] r [ i ] q [ i ] y [ i ] x [ i ] 0 184 = 69(2) + 46 184 69 46 2 - 1 3 1 69 = 46(1) + 23 69 46 23 1 1 - 1 2 46 = 23(2) + 0 46 23 0 2 0 1 Recall that (**) y [ i - 1] = x [ i ] and (*) x [ i - 1] = y [ i ] - q [ i - 1] x [ i ] Example: k = 184 , j = 69 1) First run the regular GCD algorithm: get gcd (184 , 69) = 23 2) Then calculate y [2] = 0 , x [2] = 1 3) Continue bottom-up, calculating the x [ i ] , y [ i ] from (*) and (**) 4) We are done! Note that 184( - 1) + 69(3) = 23 = gcd (184 , 69) . and we want j [ i ] x [ i ] + k [ i ] y [ i ] = gcd ( k [ i ] , j [ i ])

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 i k [ i ] = j [ i ] q [ i ] + r [ i ] k [ i ] j [ i ] r [ i ] q [ i ] y [ i ] x [ i ] 0 99 = 63(1) + 36 99 63 36 1 2 - 3 1 63 = 36(1) + 27 63 36 27 1 - 1 2 2 36 = 27(1) + 9 36 27 9 1 1 - 1 3 27 = 9(3) + 0 27 9 0 3 0 1 Recall that (**) y [ i - 1] = x [ i ] and (*) x [ i - 1] = y [ i ] - q [ i - 1] x [ i ] Example: k
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: = 99 , j = 63 1) First run the regular GCD algorithm: get gcd (99 , 63) = 9 2) Then calculate y [3] = 0 , x [3] = 1 3) Continue bottom-up, calculating the x [ i ] , y [ i ] from (*) and (**) 4) We are done! Note that 99(2) + 63(-3) = 9 = gcd (99 , 63) . and we want j [ i ] x [ i ] + k [ i ] y [ i ] = gcd ( k [ i ] , j [ i ])...
View Full Document

## This note was uploaded on 08/25/2010 for the course COMP COMP170 taught by Professor M.j.golin during the Spring '10 term at HKUST.

### Page1 / 2

L05_exgcd_print - = 99 j = 63 1 First run the regular GCD...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online