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

Function GCD

codes/cpp/Code_3_02_2.cpp:2–9  ·  view source on GitHub ↗

GCD �� Greatest Common Divisor�i�ő���񐔁j�̗�

Source from the content-addressed store, hash-verified

1// GCD �� Greatest Common Divisor�i�ő���񐔁j�̗�
2long long GCD(long long A, long long B) {
3 while (A >= 1 && B >= 1) {
4 if (A < B) B = B % A; // A < B �̏ꍇ�A�傫���� B ������������
5 else A = A % B; // A >= B �̏ꍇ�A�傫���� A ������������
6 }
7 if (A >= 1) return A;
8 return B;
9}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected