Ask Question
12 April, 04:09

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?

+4
Answers (1)
  1. 12 April, 06:18
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers