Mysterious Function

Can you identify the function f(x,y) which takes two positive integers as its argument?

1
2
3
4
5
6
7
8
9
def f(x,y):
    minimum = min(x,y)
    maximum = max(x,y)
    if minimum == 0:
        return maximum
    elif minimum == 1:
        return 1
    else:
        return f(minimum,maximum-minimum)

Greatest Common Divisor Subtraction Operator Euler's Totient Function Least Common Multiple

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Julian Yu
Mar 14, 2016

This is basically the Euclidean Algorithm

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...