Skip to content

GCD Algorithm

Published: at 오후 06:33

Table of contents

Open Table of contents

python 코드

def get_gcd(x, y):
    while y:
        tmp = y
        if x % y == 0:
            return y
        y = x % y
        x = tmp

    return y


print(get_gcd(15, 21))

How to Run

python version: 3.11.6

Run main.py

pip install pipenv
pipenv --python 3.11.6
pipenv run python3 main.py

Input

Output

3

Execution Image