A348429 Perfect powers m^k, m >= 1, k >= 2 such that m and m^k both are palindromes.
1, 4, 8, 9, 121, 343, 484, 1331, 10201, 12321, 14641, 40804, 44944, 1002001, 1030301, 1234321, 1367631, 4008004, 100020001, 102030201, 104060401, 121242121, 123454321, 125686521, 400080004, 404090404, 1003003001, 10000200001, 10221412201, 12102420121, 12345654321, 40000800004
Offset: 1
Examples
First few terms are equal to 1, 2^2, 2^3, 3^2, 11^2, 7^3, 22^2, 11^3, 101^2, 111^2, 11^4 = 121^2, 202^2, 212^2, 1001^2, 101^3, 1111^2, 111^3.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..1024 (all terms with <= 40 digits)
- Michael S. Branicky, Python program
- Gustavus J. Simmons, Palindromic Powers, J. Rec. Math., Vol. 3, No. 2 (1970), pp. 93-98 [Annotated scanned copy].
Programs
-
Mathematica
Block[{n = 10^6, nn, s}, s = Select[Range[2, n], PalindromeQ]; nn = Max[s]^2; {1}~Join~Union@ Reap[Table[Do[If[PalindromeQ[m^k], Sow[m^k]], {k, 2, Log[m, nn]}], {m, s}]][[-1, -1]]] (* Michael De Vlieger, Oct 18 2021 *)
-
PARI
ispal(x) = my(d=digits(x)); d == Vecrev(d); \\ A002113 isok(m) = if (m==1, return (1)); my(p); ispal(m) && ispower(m, , &p) && ispal(p); \\ Michel Marcus, Oct 19 2021
-
PARI
ispal(x) = my(d=digits(x)); d == Vecrev(d); \\ A002113 lista(nn) = {my(list = List(1)); for (k=2, sqrtint(nn), if (ispal(k), my(q = k^2); until (q > nn, if (ispal(q), listput(list, q)); q *= k;););); vecsort(list,,8);} \\ Michel Marcus, Oct 20 2021
-
Python
# see link for faster version def ispal(n): s = str(n); return s == s[::-1] def aupto(limit): aset, m, mm = {1}, 2, 4 while mm <= limit: if ispal(m): mk = mm while mk <= limit: if ispal(mk): aset.add(mk) mk *= m mm += 2*m + 1 m += 1 return sorted(aset) print(aupto(10**11)) # Michael S. Branicky, Oct 18 2021
Comments