It seems there is no closed form for the greatest common divisor of any two given integers.
Why is there no such formula?
Does the only way to compute the gcd is essentially to recursively apply the Euclidean algorithm?
It seems there is no closed form for the greatest common divisor of any two given integers.
Why is there no such formula?
Does the only way to compute the gcd is essentially to recursively apply the Euclidean algorithm?
Does this count? Using this result gives
$$\text{gcd}^2(m,n) = \frac{24mn}{\pi^3}\Big[-\frac{\pi \ln^2(2)}{2} + \int_{0}^{\frac{\pi}{2}} \ln |\sin(mx)| \cdot \ln |\sin(nx)| \text{ }\mathrm dx \Big]$$
There are many more integrals whose closed forms contain the GCD. (See this post) It is definitely more effective to calculate the $\gcd$ using the euclidean algorithm or the prime factorization. :)
${\displaystyle \gcd(a,b)=\log _{2}\prod _{k=0}^{a-1}(1+e^{-2i\pi kb/a})}$
– Maxime Jaccon Jan 31 '25 at 04:05Does this count?
$$(m,n)=n-2\sum_{k=1}^n\left\{\frac{k\ m}{n}\right\}$$
There certainly is a closed formula, if you have the prime factorizations.
Let $$m=\prod p_i^{m_i}\quad \& \quad n=\prod p_i^{n_i}$$
Where the product is taken over the primes $\{p_i\}$ and it is understood that only finitely many of the $\{m_i\}$ and $\{n_i\}$ are non-zero.
Then $$\gcd(m,n)=\prod p_i^{\min(m_i,n_i)}$$
This also gives an alternative to the Euclidean Algorithm. It's not all that helpful, though, because it is, in general, extremely difficult to produce the prime factorization. By contrast, the Euclidean algorithm is easy to use, even for large numbers.