Math, asked by rahulrahe007, 8 months ago

Pseudocode for the Mystery Algorithm
ALL
1. Input two integers: a, b.
2. Initialize the value of x to a and the value of y to b.
3. If x>y then set x to x-y.
4. If x=y then set y to y-x.
5. Repeat steps 3 and 4 until x=y.
6. Output x (or y) and halt.
1
What will this algorithm output in step 6 if we begin with a = 2437, b = 875
2
Pick ONE option
3
0
4
5
3
7
875
2437

Answers

Answered by harsitakumawat132007
4

Answer:

2

Step-by-step explanation:

mark as brain list............

Answered by amitnrw
5

Given : Pseudocode for the Mystery Algorithm

1. Input two integers: a, b.

2. Initialize the value of x to a and the value of y to b.

3. If x>y then set x to x-y.

4. If x=y then set y to y-x.

5. Repeat steps 3 and 4 until x=y.

6. Output x (or y) and halt.

To Find : What will this algorithm output in step 6 if we begin with a = 2437, b = 875

Solution:

a = 2437

b = 875

x = 2437 , y = 875

2437 > 875

x = 2437 - 875  = 1562

1562 ≠ 875

1562 > 875

x = 1562 - 875  = 687

687 ≠ 875

687 <  875

now x  ≠ y  also  x < y

Hence step 3 and step 4 does not do any thing and loop keeping repeating and it never comes out of the loop

as  x  ≠ y  

so it never reaches to step 6.

Hence no output

Learn More:

Draw a flow chart and write an algorithm for a program that adds all ...

https://brainly.in/question/12819501

using division algorithm prove that if X + a is a factor of FX is equal to ...

https://brainly.in/question/9908549

Similar questions