Ask Question

Pseudocode for mystry algorithm

input two integers a, b

initialize the value of x to a and the value of y to b

if x>y then set x to x-y

if x

repeat steps 3 & 4 until x = y

output x (or y) and halt

what will this algorithm ouput in step 6 if a = 2437 and b = 875?

+5
Answers (1)
  1. 28 June, 21:51
    0
    Initially if x = a = 2437 and y = 875, condition (1) that is x>y is true and output would be x = 1562 with y = 87

    Explanation:

    According to pseudo code the code will run until x becomes equal to y. Initially if x = a = 2437 and y = 875, condition (1) that is x>y is true. So next step would be x=x-y and output would be x = 1562 with y = 875. With initial values x = a = 2437 and y = 875, x becomes equal to y after 21 iterations and output is x=y=1

    X Y

    2437 875 1562 875 687 875 687 188 499 188 311 188 123 188 123 65 58 65 58 7 51 7 44 7 37 7 30 7 23 7 16 7 9 7 2 7 2 5 2 3 2 1 1 1
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Pseudocode for mystry algorithm input two integers a, b initialize the value of x to a and the value of y to b if x>y then set x to x-y if ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers