Skip to content

Sunday Times Teaser 3274 – Anarithm

by BRG on June 22, 2025

by Colin Vout

Published Sunday June 22 2025 (link)

If you rearrange the letters of a word to form another word, it’s called an anagram. So I think that if you rearrange the digits of a number to form another number, it could be called an anarithm.

Some decimal numbers when expressed in two number bases have representations that are anarithms of each other. For instance, the decimal number 66 is 123 in base 7 and 231 in base 5.

I’ve recently been looking at numbers in base 8 and base 5 and found that it is possible to have a decimal number whose representations in base 8 and base 5 are anarithms of each other.

In decimal notation, what is the largest such number?

From → Uncategorized

7 Comments Leave one →
  1. BRG permalink

  2. John Z permalink

    • Frits permalink

      @John,

      You seem to assume that there must be a solution for the “n” you have calculated.

    • BRG permalink

      Hi John,

      You could speed up your solution quite a bit since we know that the number is between 512 and 624. So possible base 5 numbers are ‘4xxx’ and base 8 numbers are ‘1xxx’. Hence we know two of the digits and your product could be replaced by a repeat of 2 with (1,4) added. We can go even further since three digits must be either (0,1,4) or (1,1,4) leaving only one digit to pick from ‘01234’.

      • John Z permalink

        The inner loop (lines 18 – 22) execute 120 times but 4xxx base 5 comprises only 125 values, so retooling my code to start at 4000 is probably about as fast:

        • BRG permalink

          Their run-times are now both dominated by the cost of
          their print statements. If rewritten as subroutines (i.e. not
          including import and output costs) they both run in less
          than 50 microseconds.

  3. John Z permalink

    Line 14 generates base 5 numbers from 0000 to 4444 (base 5) = 0 to 624 (base 10) = 0 to 1160 (base 8). Leading 0’s are stripping to determine if there is an anarithm.

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS