A378048 Numbers k such that k and k^2 together use at most 4 distinct decimal digits.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 35, 38, 40, 41, 45, 46, 50, 55, 56, 60, 63, 64, 65, 66, 68, 70, 74, 75, 76, 77, 80, 81, 83, 85, 88, 90, 91, 95, 96, 97, 99, 100, 101, 102, 105, 109, 110
Offset: 1
Examples
816 is in the sequence since 816^2 = 665856 and both together use at most 4 distinct digits. 149 is not in the sequence since 149^2 = 22201 and both together use 5 distinct digits.
Links
- Daniel Mondot, Table of n, a(n) for n = 1..10000 (first 748 terms from Jovan Radenkovicc)
- M. F. Hasler, Numbers avoiding certain digits, OEIS wiki, Jan 12 2020
- Hisanori Mishima, Sporadic tridigital solutions
- OEIS index for squares having only given digits
Crossrefs
Programs
-
Magma
[n: n in [0..1000000] | #Set(Intseq(n)) le 4 and #Set(Intseq(n) cat Intseq(n^2)) le 4];
-
Mathematica
Select[Range[0, 110], Length[Union @@ IntegerDigits@ {#, #^2}] < 5 &] (* Amiram Eldar, Nov 15 2024 *)
-
PARI
isok(k) = #Set(concat(digits(k), digits(k^2))) <= 4; \\ Michel Marcus, Nov 15 2024
-
PARI
is(n)=my(s=Set(digits(n))); #s<5 && #setunion(Set(digits(n^2)),s)<5 \\ Charles R Greathouse IV, Jan 30 2025
-
PARI
is1(n)=#setunion(Set(digits(n^2)),Set(digits(n)))<5 ok(m)=my(d=concat(apply(k->digits(lift(k)), [m,m^2])) test(d)=my(v=List(),D=10^d); for(n=0,D-1, if(ok(Mod(n,D)), listput(v,n))); Vec(v) res=test(8); \\ build a list of residues mod 10^8 D=diff(concat(res,res[1]+10^8)); #D u=List(); for(n=0,10^7, if(is1(n) && !setsearch(n,res), listput(u,n))); \\ build exceptions setminus(select(is1,[0..n]),list(n)) list(lim)=my(v=List(u)); forstep(n=0,lim,D, if(is1(n), listput(v,n))); Vec(v) \\ Charles R Greathouse IV, Jan 30 2025
-
Python
def ok(n): return len(set(str(n)+str(n**2))) <= 4 print([k for k in range(111) if ok(k)]) # Michael S. Branicky, Nov 18 2024
Formula
Trivially, a(n) >> n^1.66... where the exponent is log(10)/log(4) (A154155). - Charles R Greathouse IV, Jan 30 2025
Comments