Module: (Python) Practicum 4. Euclid's Algorithm


Problem

3/6

To understand recursion, you need to understand recursion

Problem

There is another version of Euclid's algorithm, in which the operation of subtraction is replaced by the operation of calculating the remainder.
This version is considered preferable today, since it contains, on average, a significantly smaller number of steps. However, in the days when computers were large and slow, the division operation could be a complex procedure in itself. And then the first version of the algorithm could be more efficient.

Implement Euclid's algorithm by replacing subtraction with a modulo operation.

Two natural numbers A and B are given. Write a function nod(A, B) that returns the greatest common divisor of A and B.
 
Program examples
# Input Output
1 12 42 6

Remember that you can't use loops in your solution.
You are only required to write a function, nothing needs to be entered and output!