# Sum of digits of $a^b$ equals $ab$

The following conjecture is one I have made today with the aid of computer software.

Conjecture:

Let $$s(\cdot)$$ denote the sum of the digits of $$\cdot$$ in base $$10$$. Then the only integer values $$a,b>1$$ that satisfy $$s(a^b)=ab$$ are $$(2,2),(3,3),(3,6),(3,9)$$ and $$(3,27)$$.

Remarks:

• The number of digits of an integer $$n$$ is $$1+\lfloor\log_{10}n\rfloor$$ where $$\lfloor\cdot\rfloor$$ denotes the floor function. This means that $$s(a^b)<9+9\lfloor b\log_{10} a\rfloor$$ as each digit takes a value of at most $$9$$. From this plot it is evident that the equality will never hold for $$a\ge 9$$, after checking the first $$21$$ values of $$b$$. Therefore it suffices to consider $$2\le a\le 8$$.

• I have excluded the case $$b=1$$ as it is trivial - it forces $$a$$ to be a single-digit integer.

• In PARI/GP the code is given by mfun(b)={for(i=2,8,for(j=2,b,if(sumdigits(i^j,10)==i*j,print(i," ",j))));} and tests up to $$b\le 10^6$$ verify the above conjecture.

Aside:

• The equation $$s(ab)=a+b$$ is much simpler to solve. From here, the upper bound $$a\le 23$$ is apparent and for these values of $$a$$, we can form the upper bound $$b\le 22$$ as there will be no solutions when the red line lies above the blue lines. This $$23\times22$$ grid can be computed through software and it is found that the only solutions are $$(a,b)=(2,2),(3,6),(6,3).$$ The similarity in the first two solutions with the conjectured solutions may only be coincidental.

Advances on this will be appreciated.

• So, you are only considering base-10? If such a conjecture is true, you would expect it to be true for any base. Commented Feb 24, 2019 at 17:17
• Though, in light of @alex811's comment, one wonders what the set of pairs would be in other bases. For example, $(a,a)$ will work in any base where $(a,a)$ is represented by a single digit. I also wonder if the fact that $3^2 = 9 = 10-1$ is of any relevance. Commented Feb 24, 2019 at 22:00
• If $3\mid a$ then $9\mid s(a^b)$ so you need either $9\mid a$ or $3\mid b$. Don't know if that helps. I prepared a largely useless plot here related to the case $a=2$. I found this somewhat related post the most delightful contribution around this theme. Commented Feb 25, 2019 at 10:31
• Showing that $s_2(2^b) < 2b$ for $b$ large is probably very difficult. I don't know how to show, for instance, that a power of $2$ can't have all 7's,8's, or 9's in its decimal expansion. Commented Mar 2, 2019 at 20:29
• @TheSimpliFire I posted a new question regarding my effort to solve your conjecture, to get advice about some asymptotic relation for s(a^b). Any help would be appreciated. I am not a professional mathematician, but I think it's worth reading! math.stackexchange.com/questions/3370010/… Commented Sep 26, 2019 at 15:47

I like to crack numbers but this time I'll pass. It's highly unlikely that there is any other solution. I have created a few plots of function:

$$f(a)=s(a^b)-ab$$

...for $$a=2,3,4,5,6,7,8$$ and $$b\in [1,4000]$$. All these plots look the same. The function slides towards negative infinity in a pretty linear fashion, with very little variation from the straight line. If you accept bets, I can bet a house that there are no other solutions except small ones that you already listed.

Mathematica code:

For[a=2,a<=8,a++,DiscretePlot[Total[IntegerDigits[a^b,10]]-a*b,{b,2,4000},Filling->f,Joined->False] // Print]


$$a=2$$

$$a=3$$

$$a=4$$

$$a=5$$

$$a=6$$

$$a=7$$

$$a=8$$

• It looks like there may be hope in providing a linear upper bound for $f$, which would prove the result. A weak one would suffice. Commented Apr 21, 2019 at 7:54

Here is a heuristic argument (not a proof sadly, but too long for a comment).

The sequences $$2^n,3^n,\dots,9^n$$ are known to follow Benford's law, i.e., their first digit has a probability $$\log_{10}\left(1+\frac{1}{d}\right)$$ of being $$d$$; their second digit has a probability $$\log_{10}\left(1+\frac{1}{10+d}\right)+\log_{10}\left(1+\frac{1}{20+d}\right)+\dots+\log_{10}\left(1+\frac{1}{90+d}\right)$$ of being $$d$$, etc.

Here, "probability" is to be understood as asymptotic density. For instance, for the first digit of the sequence $$2^n$$, we have: $$\lim_{n\to\infty}\frac{|\{k\in\{1,\dots,n\}:2^k\text{ has d as first digit}\}|}{n} = \log_{10}\left(1+\frac{1}{d}\right)$$ and more generally, for all $$a \in \{2,\dots,9\}$$: $$\lim_{n\to\infty}\frac{|\{k\in\{1,\dots,n\}:a^k\text{ has d as j-th digit}\}|}{n} = \sum_{i=10^{j-2}}^{10^{j-1}-1}\log_{10}\left(1+\frac{1}{10i+d}\right)$$ and as the last quantity approaches $$\frac 1 {10}$$ as $$j \to \infty$$, the $$j$$-th digit of $$a^n$$ are almost equidistributed.

If we heuristically take these probabilities at face value, the sum of the digits of $$a^n$$ should match the sum of their expected values, and, apart from the first figures, this expected value is close to $$4.5$$. Thus, we should expect to have: $$s(a^n) \approx 4.5(1+\lfloor n\log_{10}a\rfloor) \approx 4.5 n\log_{10}a$$ and thus: $$s(a^n) - an \approx (\underbrace{4.5\log_{10} a - a}_{<0 \textrm{ for all } a})n \to_{n \to\infty} -\infty$$ This aligns with the graphs provided by @Oldboy. For instance, for $$a=6$$, we should expect a slope of $$4.5\log_{10}6 - 6 \approx -2.50$$, which matches the observed slope of $$-10000/4000$$.

Also not an answer, but it greatly reduces the set of possible solutions... We know for a fact that the difference between $$n$$ and $$s\left(n\right)$$ is always a multiple of $$9$$: $$\left(n-s\left(n\right)\right)\mod9=0$$ So if $$s\left(a^{b}\right)=ab$$, then: $$\left(a^{b}-ab\right)\mod9=0$$ Therefore, for $$2\leq a \leq 8$$, $$b$$ must be of the following forms: $$b\begin{cases} 3n & \iff a=3~or~6\\ 9n+1 & \iff a=4~or~7\\ 18n+1~or~18n+2 & \iff a=2\\ 18n+1~or~18n+8 & \iff a=8\\ 18n+1~or~18n+14 & \iff a=5\\ \end{cases}$$