OFFSET
1,2
EXAMPLE
841 is a term since it is equal to 29^2 and its digits are all powers of 2: 8 = 2^3, 4 = 2^2, and 1 = 2^0;
1331 is a term since it is equal to 11^3 and its digits are all powers of 3: 1 = 3^0 and 3 = 3^1.
MATHEMATICA
perfectPowerQ[n_] := n == 1 || GCD @@ FactorInteger[n][[All, 2]] > 1; (* A001597 *)
nterms=20; list={}; len=0; n=1; While[len <=nterms, If[perfectPowerQ[n] &&(SubsetQ[{0}, dig=IntegerDigits[n]] || SubsetQ[{1, 2, 4, 8}, dig] || SubsetQ[{1, 3, 9}, dig] || SubsetQ[{1, 5}, dig] || SubsetQ[{1, 6}, dig] || SubsetQ[{1, 7}, dig]), AppendTo[list, n]; len++]; n++]; list
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Stefano Spezia, Jun 26 2025
STATUS
approved
