login
Numbers k such that k and k^2 use only the digits 2, 3, 5 and 6.
1

%I #18 May 10 2024 10:59:46

%S 5,6,25,235,256,23566,2352365325,23523653335

%N Numbers k such that k and k^2 use only the digits 2, 3, 5 and 6.

%C Generated with DrScheme.

%C No more terms < 10^26. - _Robert Israel_, Nov 24 2023

%H Jonathan Wellons, <a href="https://web.archive.org/web/20090206165028/http://jonathanwellons.com/shared-digits/">Tables of Shared Digits</a> [archived]

%e 2352365325^2 = 5533622622262355625.

%p Good := {2, 3, 5, 6}: R:= 5, 6:

%p G[1]:= {5, 6}:

%p for d from 2 to 26 do

%p G[d]:= select(t -> member(floor((t^2 mod 10^d)/10^(d-1)), Good), map(t -> seq(10^(d-1)*i+t, i=Good), G[d-1]));

%p for t in G[d] do

%p if convert(convert(t^2, base, 10), set) subset Good then R:= R, t fi

%p od od:

%p sort([R]); # _Robert Israel_, Nov 24 2023

%t fQ[n_] := Block[{d = DigitCount@ n}, Total@ Delete[d, {{2}, {3}, {5}, {6}}] == 0]; Select[Range@ 100000, fQ@ # && fQ[#^2] &] (* _Michael De Vlieger_, Apr 29 2015 *)

%o (Python)

%o from itertools import product

%o A137079_list = [int(''.join(a)+b) for l in range(10) for a in product('2356',repeat = l) for b in ('5','6') if set(str(int(''.join(a)+b)**2)) <= {'2','3','5','6'}]

%o # _Chai Wah Wu_, Apr 29 2015

%K base,nonn,more

%O 1,1

%A Jonathan Wellons (wellons(AT)gmail.com), Jan 22 2008