10
$\begingroup$

I have written a small program that calculates the base representation of a number, and checks if that representation is a palindrome (also check if the length is at least 2, since a length of 1 is trivially palindromic).

What I have found is that there is a "gap", which becomes larger as the numbers that are considered goes higher. In the image below, I have considered all numbers from 2 to 30000. There also seems to be 2 smaller gaps forming in between each of the "segments".

Is there a reason that there is a gap?

Edit: the condition on being palindromic are considering the concatenation of the decimal representations using code found here: https://stackoverflow.com/questions/10184577/java-recursion-program-convert-a-base-10-number-to-any-base. For example, I consider 5999 palindromic in base 111, because its representation is 54 : 5 (base 111), and the concatenation of the digits (545) is palindromic.

Here is considering all numbers $\le 3*10^4$:

The number n vs the number of base representations of n for which it is a palindrome.

Here is considering all numbers $\le 10^5$:

enter image description here

$\endgroup$
23
  • $\begingroup$ This is rather interesting. You should run this again on a higher range of numbers to see if it branches again. $\endgroup$ – Mike Pierce Dec 8 '14 at 18:52
  • $\begingroup$ @mapierce271 Thanks! I am working on automating the process now so that I can go into higher ranges. $\endgroup$ – Ryan Dec 8 '14 at 18:53
  • 1
    $\begingroup$ The first thing that jumps to mind (and this doesn't explain the gap directly) is divisibility considerations - a number is a 2-digit palindrome in a given base $b\gt \sqrt{n}$ if it's of the form $k\cdot(b+1)$, so numbers with many small prime factors will have many palindromic base representations. You should be able to do a vaguely similar analysis of 3-digit palindromes, and the number of bases $b\lt\sqrt[3]{n}$ for which $n$ is a (many-digit) palindrome should be a vanishingly small part of the total. $\endgroup$ – Steven Stadnicki Dec 8 '14 at 19:34
  • 1
    $\begingroup$ Hmm. Even if you were, I can't understand where this graph is coming from. You show that, say, $5999$ is a (nontrivial) palindrome in dozens of different bases. I only see it to be a palindrome in base $28$, base $856$, and base $5998$. What am I missing? $\endgroup$ – mjqxxxx Dec 8 '14 at 19:52
  • 2
    $\begingroup$ @mjqxxxx You're right, my code is probably incorrect. I have 5999 being palindromic in base 111, but the representation is 54 : 5 (base 111), based off of the code here: stackoverflow.com/questions/10184577/… $\endgroup$ – Ryan Dec 8 '14 at 19:58
1
$\begingroup$

I don't have an answer as to why, but I've explored the function (using the Python code below), and identified the principal branches. The first division is into even bases (the top trunk) and odd bases (the bottom trunk). The second division is into bases that are divisible by $5$ (the top branch on each trunk) and bases that are not.

There are further refinements that can be seen on closer inspection, as well. For instance, the figure below shows just those bases that are multiples of $10$, with the dominant $\sqrt{b}$-ish behavior subtracted off. There is clearly a consistent difference between bases that are divisible by $20$ and those that are only divisible by $10$.

enter image description here

def decDigits(n, b):
  if n==0: return []
  return decDigits((n - (n%b))/b, b) + list(str(n%b))

def isPalindrome(n, b):
  fr = decDigits(n, b)
  rv = list(fr)
  rv.reverse()
  return fr == rv

def numBases(n):
  return len(filter(lambda(b):isPalindrome(n, b), xrange(2, n)))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.