This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A345396 #8 May 16 2022 02:01:53 %S A345396 2,12049,52673,937253,1000099,3844790441,62911443401,1052000152157 %N A345396 a(n) is the least prime p such that {p, p^2, ..., p^n} are all digitally balanced numbers in base 2 (A031443). %C A345396 a(9) > 2.5 * 10^12, if it exists. %e A345396 a(1) = 2 since 2 is digitally balanced: its binary representation, 10, has the same number of 0's and 1's. %e A345396 a(2) = 12049 since both 12049 and 12049^2 are digitally balanced: the binary representation of 12049, 10111100010001, has 7 0's and 7 1's, and the binary representation of 12049^2, 1000101001110011111100100001, has 14 0's and 14 1's. %t A345396 balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length @ d) && Count[d, 1] == m/2]; f[p_] := Module[{e = 0, r = p}, While[balQ[r], r *= p; e++]; e]; mx = 5; s = Table[0, {mx}]; c = 0; p = 2; While[c < mx, k = f[p]; Do[If[s[[i]] == 0, s[[i]] = p; c++], {i, 1, k}]; p = NextPrime[p]]; s %o A345396 (Python) %o A345396 from itertools import count, islice %o A345396 from sympy import isprime %o A345396 from sympy.utilities.iterables import multiset_permutations %o A345396 def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1") %o A345396 def A066196gen(): %o A345396 yield from filter(isprime, (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1)))) %o A345396 def a(n): %o A345396 for p in A066196gen(): %o A345396 if all(isbalanced(p**i) for i in range(2, n+1)): %o A345396 return p %o A345396 print([a(n) for n in range(1, 6)]) # _Michael S. Branicky_, May 15 2022 %Y A345396 Subsequence of A031443, A066196 and A345395. %Y A345396 Cf. A345397. %K A345396 nonn,base,more %O A345396 1,1 %A A345396 _Amiram Eldar_, Jun 17 2021