Given two non-negative integers \(a\) and \(b\), compute their greatest common divisor—i.e., the largest integer \(d\) such that \(d\) divides both \(a\) and \(b\). In notation, this is written as \(d \mid a\) and \(d \mid b\), which means that there exist integers \(k\) and \(\ell\) such that \(a = dk\) and \(b = d\ell\).
Given two non-negative integers \(a\) and \(b\), compute their greatest common divisor—i.e., the largest integer \(d\) such that \(d \mid a\) and \(d \mid b\).
Two non-negative integers \(a\) and \(b\), (optionally, with \(a \geq b\)).
An integer \(d\), the greatest common divisor of \(a\) and \(b\).
The GCD is fundamental in number theory and appears in many areas such as simplifying fractions, modular arithmetic, cryptography (e.g., RSA), and algorithmic problems like computing least common multiples (LCMs) and Diophantine equations.
Input: \(a = 48, \; b = 18\)
Output: \(6\)
Explanation: \(6\) divides both 48 and 18, and no larger number does.
Input: \(a = 101, \; b = 103\)
Output: \(1\)
Explanation: 101 and 103 are relatively prime.