파이썬 gcd()

Jmnote (토론 | 기여)님의 2020년 7월 12일 (일) 01:39 판

1 개요

Python gcd()
파이썬 gcd()
from math import gcd
print( gcd(20,8) ) # 4
print( gcd(12,21) ) # 3
def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a

print( gcd(12,21) ) # 3
print( gcd(20,8) ) # 4

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}