This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
GoalIn this puzzle you will have to calculate the greatest common divisor (GCD) of two numbers (a and b) thanks to Euclid's algorithm, but you will not have to return just the result but also the different calculation steps.
If you are asked to calculate the GCD of 25 and 3 you must return:
In mathematics, Euclid's algorithm is an algorithm that calculates the GCD of two integers, that is, the largest integer that divides the two integers, leaving a zero remainder. Euclid's algorithm follows a simple method which is defined by the following equality:
GCD(a,b) = GCD(b,
Divide b by the remainder of the division of b by a and continue until you get r=0.
Line 1: An integer a and integer b separated by a space
the different stages of calculating Euclid's algorithm
a > b
25=3*8+1 3=1*3+0 GCD(25,3)=1
A higher resolution is required to access the IDE