0

Let us say that I have two numbers $m$ and $n$ and $a$ is a positive number bigger than 2. Also assume that base-$a$ representations of $m$ and $n$ are:

$m = r_{M}a^{M} + r_{M-1}a^{M-1} + ... + r_{1}a + r_{0}$ and $n = s_{N}a^{N} + s_{N-1}a^{N-1} + ... + s_{1}a + s_{0} $

where all the $r_{j}$ and $s_{j}$ are in $\{0, 1, ... , a-1\}$.

I was wondering if I could calculate the quantity $gcd (m, n)$, without going back to base-$10$ representations? I have never even heard of $gcd$ in other bases before.

Is there a way to easily know when these two numbers $m$ and $n$ are relatively prime, again without converting back to base-$10$ representations?

  • 5
    A standard method for computing the gcd is the Euklidean algorithm, and that is independent of the representation in a base. – Martin R Nov 22 '20 at 03:29
  • Martin R's comment is definitely better than my alternative approach: use the fundamental theorem of arithmetic, but first, convert all pertinent prime numbers to the relevant base. – user2661923 Nov 22 '20 at 04:22
  • Going by its name, I would guess that the Euclidean algorithm was invented before decimal notation. Am I wrong? – bof Nov 22 '20 at 07:31

1 Answers1

0

To implement the Euclidean algorithm we require only an effective (Euclidean) "division with smaller remainder" algorithm, and this can be implemented the same way in any radix - in analogy with the grade school long-hand decimal division algorithm (for integers - unlike polynomials - it suffices to have a subtraction algorithm and, of course, a comparison test, to determine the least).

Your prior answers imply you know some algebraic number theory so you must be familiar with basic ring theory, so let's view it from that perspective. The "representation" in radix representation means we have have a ring ${\rm\color{#c00}{isomorphism}}\ h\,$ that maps integers into their radix reps, with the radix arithmetic operations.

This ring isomorphism necessarily preserves the division algorithm: $ $ in the division $\,a\div b,\,$ if $\, a = q\,b+r,\ 0\le r < b\,$ $\rm\color{#c00}{then}$ $\,h(a) = h(q)h(b) + h(r),\ 0\le h(r) < h(b).\,$ By uniqueness of the quotient and remainder, $\,h(q)\,$ and $\,h(r)\,$ are the quotient and remainder of $\,h(a)\div h(b).\,$ This implies that the Euclidean remainder sequence of $\,\gcd(h(a),h(b))\,$ is the image under $h$ of the sequence for that of $\,\gcd(a,b).\,$ Thus the Euclidean algorithm works exactly the same in any isomorphic ring representation (though the "internal" calculations in the (radix) long division algorithm will differ because they do depend on the radix digits).

Of course it's easy to directly deduce that that ring isomorphisms preserve gcds and ideals (and their generators), but your question concerns specifically how the Euclidean algorithm maps under an isomorphism, so I focused on that.

Bill Dubuque
  • 272,048
  • Thank you for that explanation. I do believe Euclidean algorithm works and hence the Bezout's Identity holds too. Perhaps that is my best hope as to determining when two positive integers, written in base $a$, are relatively prime. – HumbleStudent Nov 23 '20 at 04:12
  • @HumbleStudent If you know how to divide integers (with remainder) in radix $10$ (decimal) then it should be clear how to do the same in any radix. Whether or nor integers are coprime (or prime) is independent of their (radix) representation - see the linked post. – Bill Dubuque Nov 23 '20 at 08:56
  • Btw, you have asked 67 questions but given only 9 votes. Were most of the answers to your question so unhelpful that they didn't deserve a vote? – Bill Dubuque Nov 23 '20 at 09:02