1

Find the sum of all positive integers such that their expression in base $7$ digits is the reverse of their expression in base $16$ digits. Express your answer in base $10$.

I tried expressing the digits as $d_1$ $d_2$... and making separate equations but that didn't work. Help!

J. W. Tanner
  • 60,406
Noah D.
  • 123

2 Answers2

3

In particular, these numbers have at most as many digits in base seven as they have in base sixteen. So, if $16^{k-1} \leq n < 16^{k}$ is such an integer, then $n$ has at most $k$ digits in base $7$, so $n < 7^k$. Thus $16^{k-1} < 7^k$. This forces $k \leq 3$. By assumption, you know that $n$ has as base-16 digits only $0,1,2,3,4,5,6$.

The one-digit numbers contribute $21$.

For the two-digit numbers: write $n$ as $ab$ in base $16$. Then $16a+b=7b+a$, so $15a=6b$ ie $5a=2b$, so $a=2,b=5$ is the only solution, ie $n=37$.

For the three-digit numbers: write $n$ as $abc$, then $256a+16b+c=49c+7b+a$, thus $255a+9b=48c$, hence $85a+3b=16c$. As $a > 0$, $c > 5$ so $c=6$ and $3|85a$, so $16c=85a+3b > 255$, so $c > 6$, impossible.

So finally it’s $21+37=58$.

Aphelli
  • 34,439
1

If $n=a_k 16^k + \ldots + a_1 16+ a_0= a_0 7 ^k + \ldots a_{k-1}7 + a_k$, with $a_k \geq 1$, then by $n < 7^{k+1}$ we have $16 ^k < 7^{k+1}$. This means that $k\leq 3$ (can manually check this). This limits the search space considerably. Moreover, If the set of coefficients in both expansions is the same, then each $a_i \leq 6$. this makes the problem amenable to a computer search if that suffices for your purposes.

To further reduce the problem, if $a_k = 2$, then $2 \cdot 16^k \leq n < 7^{k+1}$ which gives $k\leq 2$ in this case. This should be fairly easy to code up.

Slugger
  • 5,556
  • $k \le 2$ since $16^3>7^4$. – player3236 Sep 07 '20 at 20:47
  • It looks like you are assuming $a_k\not=0$. – Barry Cipra Sep 07 '20 at 20:47
  • @BarryCipra That assumption is in their first sentence. – player3236 Sep 07 '20 at 20:48
  • 1
    @player3236, I read the OP's problem somewhat differently: take a number written in base $7$, reverse the digits, read it as a number base $16$, and see if it's the same number. That reading allows for starting $0$'s. It'll be nice to know which reading the OP intends. – Barry Cipra Sep 07 '20 at 20:55
  • @BarryCipra That is also my interpretation, but I was merely pointing out that the current answer has mentioned the assumption. – player3236 Sep 07 '20 at 20:57
  • @BarryCipra, that is an interesting point indeed, I had not parsed it that way. The accepted answer seems to suggest that your interpretation is not what the OP was after though – Slugger Sep 07 '20 at 20:58
  • @player3236, ah, sorry, I somehow missed that, and thought you were referring to the OP in your first reply. I've been entertaining myself for the last few minutes looking for 3- and 4-digit examples with leading $0$'s when written backwards. – Barry Cipra Sep 07 '20 at 21:10
  • 1
    @BarryCipra Your intuition is correct! I wrote a program to check values up to $7^{10}$, and found $271843670_{10} = 6510430100_7 = 0010340156_{16}$ (and no more). This proves that, ironically, OP did not intend for base7 numbers ending in zeroes. – player3236 Sep 08 '20 at 04:10
  • @player3236, nice! – Barry Cipra Sep 08 '20 at 11:37