Recursive expression memo

Euclidean algorithm

Correction: 2020.3.5

Normal writing

main.py


def euclid_algolithm_1(a, b):
    while True:
        r = a % b
        if r == 0:
            return b
        a, b = b, r

Write in recursive representation

main.py


def euclid_algolithm_2(a, b):
    r = a % b
    if r == 0:
        return b
    return euclid_algorithm_2(b, r)

Recommended Posts

Recursive expression memo
python regular expression memo
gzip memo
Raspberry-pi memo
Pandas memo
HackerRank memo
Python memo
python memo
graphene memo
Flask memo
pyenv memo
Matplotlib memo
pytest memo
Python memo
Install Memo
BeautifulSoup4 memo
Recursive zip
networkx memo
python memo
tomcat memo
command memo
Lambda expression
Generator memo.
psycopg2 memo
Python memo
SSH memo
Command memo
Recursive function
Memo: rtl8812
pandas memo
Shell memo
Python memo
Pycharm memo
Python memo