파이썬[Python]: math - gcd 함수

math 모듈 - gcd 함수(function)


/// 설명

인자로 들어온 수들의 최대 공약수를 구합니다.
인자가 없거나, 모두 0 이면 0을 반환합니다.

※ 형식
math.gcd(*integers)

reference
https://docs.python.org/3/library/math.html#module-math

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
import math
 
print(math.gcd())  # 0
print(math.gcd(0000))  # 0
print(math.gcd(3000))  # 3
print(math.gcd(3100))  # 1
print(math.gcd(12345))  # 1
print(math.gcd(100200))  # 100
 
 
# the greatest common divisor
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수