"파이썬 gcd()"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
==개요==
==개요==
;Python gcd()
;Python gcd()
;파이썬 gcd()


<source lang='Python'>
<source lang='Python'>

2018년 7월 14일 (토) 21:37 판

1 개요

Python gcd()
파이썬 gcd()
from fractions 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 }}