MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / GCD

Function GCD

codes/python/Code_3_02_1.py:3–8  ·  view source on GitHub ↗
(A, B)

Source from the content-addressed store, hash-verified

1# 正の整数 A と B の最大公約数を返す関数
2# GCD は Greatest Common Divisor(最大公約数)の略
3def GCD(A, B):
4 answer = 0
5 for i in range(1, min(A, B) + 1):
6 if A % i == 0 and B % i == 0:
7 answer = i
8 return answer
9
10A, B = map(int, input().split())
11print(GCD(A, B))

Callers 1

Code_3_02_1.pyFile · 0.70

Calls 1

minFunction · 0.85

Tested by

no test coverage detected