fr
fr

Question from the Algorithmics - Fundamentals test

Write a function to calculate the Greatest Common Divisor of two numbers a and b (0<=b<=a and a=qb +r)

Hard

The function calcPGCD is used to calculate the Greatest Common Divisor of two numbers a and b (0<=b<=a and a=qb +r):

function calcPGCD(a, b) {
            r = a%b;
            If r != 0 {
                   a <-- b;
                   b <-- r;
                   
            display calcPGCD(a, b);
   } 
 }

What does this code display when a is 21 and b is 15?

Author: Vincent CotroStatus: Published(Update)Question passed 374 times
Edit
-1
Community Evaluations
developer avatar
Ambiguous
Auteur anonyme
10/04/2025
Etant donné que le langage n'est pas précisé, le comportement de cet algorithme est incompréhensible