Answer to Question #317997 in Algorithms for asdasd

Question #317997

Using the consecutive Integer Checking Algorithm, solve the GCD of the following pair of numbers. (Show your complete solution.)



1. GCD (19, 7)

1
Expert's answer
2022-03-26T06:42:39-0400
Find GCD(19, 7):
initial values: m = 19, n = 7

while n != 0 do  :      7 != 0
    r <- m mod n :      r <- 19 mod 7 = 5
    m <- n       :      m <- 7
    n <- r       :      n <- 5

while n != 0 do  :      5 != 0
    r <- m mod n :      r <- 7 mod 5 = 2
    m <- n       :      m <- 7
    n <- r       :      n <- 2

while n != 0 do  :      2 != 0
    r <- m mod n :      r <- 5 mod 2 = 1
    m <- n       :      m <- 2
    n <- r       :      n <- 1

while n != 0 do  :      1 != 0
    r <- m mod n :      r <- 2 mod 1 = 0
    m <- n       :      m <- 1
    n <- r       :      n <- 0

while n != 0 do  :      0 == 0

return m         :      return 1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS