Notation: For any positive integer $x$, let $\operatorname{Ones}(x)$ denote the Hamming weight of $x$ (i.e., the number of $1$s in the binary numeral for $x$), and let $\operatorname{OddPart}(x)$ denote the odd part of $x$ (i.e. the largest odd divisor of $x$).
While computing some Hamming weights, I was surprised to see the following behavior: It seems that for any given positive integer $b$, $\operatorname{Ones}(b^{(10^k)})$ has the same leading decimal digits for all sufficiently large $k$. Furthermore (with help of OEIS), these leading digits are discovered to be those of $\log_4\operatorname{OddPart}(b)$ in every case except when $b$ is a power of two (in which case there is of course only one $1$ in the numeral of $b$).
Examples: It's only necessary to look at odd $b$ because $\operatorname{Ones}(b^n) = \operatorname{Ones}(\operatorname{(OddPart}(b))^n),$ since multiplying by a power of two just appends $0$s to the binary numeral.
b Ones(b^10^9) Ones(b^10^9)/10^9 ≈ log_4(b)
----------------------------------------------------
1 1 0.0000 0.0000
3 792490796 0.7925 0.7925
5 1160951533 1.1610 1.1610
7 1403656246 1.4037 1.4037
9 1584925047 1.5849 1.5850
11 1729722034 1.7297 1.7297
13 1850206247 1.8502 1.8502
15 1953457439 1.9535 1.9534
123 3471255304 3.4713 3.4713
4567 6078486804 6.0785 6.0785
Numerically, the same behavior is found to occur for ${\operatorname{Ones}(b^n)\over n}$ with sufficiently large $n$ not necessarily a power of ten, leading to the following conjecture:
For any positive integer $b$, $$\lim_\limits{n\to\infty}{\operatorname{Ones}(b^n)\over n}= \log_4 \operatorname{OddPart}(b).$$
Question: Can someone suggest how to prove this, and/or provide a source in the literature?
(There is a slightly related question here.)
SageMath code for the above table:
for b in [1 .. 15, step=2] + [123, 4567]:
if is_odd(b):
ones = (b**10**9).popcount()
print(f"{b:4} {ones:12} {float(ones/10**9):7.4f} {float(log(b,4)):7.4f}")
Update (12/18/2022):
The "random digits" heuristic described in the comment by @HagenvonEitzen lends plausibility to the following more general conjectures, which do indeed appear to be borne out numerically (using SageMath):
For positive integers $p, x$, define
- $N_p(x)\overset{def}{=}$ the number of nonzero digits in the base-$p$ numeral for $x$,
- $S_p(x)\overset{def}{=}$ the sum of all the digits in the base-$p$ numeral for $x$.
- $R_p(x)\overset{def}{=}$ the result of dividing $x$ by the largest power of $p$ that divides $x.$
- $Z_p(x)\overset{def}{=}\min\left({e_1^\prime\over e_1},\ldots,{e_k^\prime\over e_k}\right),$ where in standard form the prime factorization of $p$ is $p=\prod_{i=1}^k p_i^{e_i}$, and $e_i^\prime$ is the exponent of $p_i$ in the prime factorization of $x$.
Claim: If $p, b$ are positive integers, then
$$\lim_\limits{n\to\infty}{N_p(b^n)\over n}= {p-1\over p}\big(\log_p(R_p(b))-Z_p(R_p(b))\big).$$
$$\lim_\limits{n\to\infty}{S_p(b^n)\over n}= {p-1\over 2}\big(\log_p(R_p(b))-Z_p(R_p(b))\big).$$
The reasoning is as follows, where we let $r=R_p(b)$:
$r$ is just the result of removing all trailing $0$s (if any) from the base-$p$ numeral of $b$, which affects neither the number of nonzero digits nor the sum of all the digits; hence, $N_p(b^n)=N_p(r^n)$ and $S_p(b^n)=S_p(r^n)$.
Now some of the base-$p$ digits of $r^n$ may also be trailing $0$s. This number (say $z\ge 0$) is the largest $m$ such that $p^m$ divides $r^n$, which is seen to be the largest $m$ such that $m e_i\le n e_i^\prime$ for all $i\in 1..k,$ where the $e_i$ are the exponents in the prime factorization of $p=\prod_{i=1}^\infty p_i^{e_i}$ and $e_i^\prime$ is the exponent of $p_i$ in the prime factorization of $r$. Thus $z$ is the largest $m$ such that $m\le n Z_p(r);$ hence, $z\sim n Z_p(r)$ as $n\to\infty$.
Example: $p=2^3 5^7, (e_1,e_2)=(3,7);r=2^1 3^3 5^2,(e_1^\prime,e_2^\prime)=(1,2);Z_p(r)=\min(1/3,2/7)=2/7.$
Hence, (number of base-$p$ digits of $b^n$ that are not trailing $0$s) $\sim n \log_p(r)- n Z_p(r).$
If the digits that are not trailing zeros tend to occur with approximately equal frequencies, then we obtain the above results (1) and (2):
$$N_p(r^n)\sim n\ \big(\log_p(r)- Z_p(r)\big)\ {p-1\over p}$$ and $$S_p(r^n)\sim n\ \big(\log_p(r)- Z_p(r)\big){0+1+2+...+(p-1)\over p}=n\ \big(\log_p(r)- Z_p(r)\big)\ {p-1\over 2}.$$
Note that $Z_p(r)=0$ iff some prime divisor of $p$ is not a divisor of $r$.