The weighted greatest common divisor \(\wgcd\) is a fundamental tool in the arithmetic of weighted projective spaces, playing a key role in the definition of weighted heights. While the \(\wgcd\) can be computed via prime factorization or using an LCM-based formula, these methods become inefficient for large integers due to the cost of factorization.
In this paper we introduce a Euclidean-type algorithm for computing the \(\wgcd\) of a tuple of integers \(\x = (x_0, \ldots, x_n) \in \Z^{n+1}\) with respect to a given weight vector \(\w = (q_0, \ldots, q_n) \in \N^{n+1}\). For the two-dimensional case we prove that, under an appropriate ordering of the weights, the classical Euclidean reduction using modular arithmetic preserves the \(\wgcd\). This leads to an algorithm that runs in \(O(\log \min(|x_0|, |x_1|))\) modular operations, completely avoiding factorization.
We extend the algorithm to arbitrary dimension using the recursive decomposition formula
\[
\wgcd_{\w}(\x) = \wgcd_{(1,q_n)}(\wgcd_{\wpow{n}}(\xpow{n}), x_n),
\]
where \(\wpow{n} = (q_0, \ldots, q_{n-1})\) and \(\xpow{n} = (x_0, \ldots, x_{n-1})\). The resulting algorithm computes the \(\wgcd\) in \(O(n\log^3 M)\) bit operations, where \(M = \max_i |x_i|\).
Finally, we provide a complete implementation in Python and demonstrate its efficiency through numerical experiments.
Publication Date: 2026-06-21