login
Numbers n such that n^2 has only digits 0, 4 and 8.
2

%I #21 Sep 08 2024 12:05:12

%S 0,2,20,22,200,202,220,298,2000,2002,2020,2022,2200,2202,2980,20000,

%T 20002,20020,20022,20200,20220,22000,22002,22020,28998,29800,200000,

%U 200002,200020,200022,200200,200202,200220,202000,202002,202200,220000,220002,220020,220200,289980,298000,632522,2000000

%N Numbers n such that n^2 has only digits 0, 4 and 8.

%C n = 2*m where m^2 has only digits 0, 1 and 2. - _Robert Israel_, Jul 17 2018

%H Robert Israel, <a href="/A202170/b202170.txt">Table of n, a(n) for n = 1..204</a>

%p Res:= NULL:

%p for x from 0 to 3^12 do

%p L:= convert(x,base,3);

%p y:= add(L[i]*10^(i-1),i=1..nops(L));

%p if issqr(y) then

%p Res:= Res, 2*sqrt(y)

%p fi

%p od:

%p Res; # _Robert Israel_, Jul 17 2018

%t Select[Sqrt[FromDigits[#]]&/@Tuples[{0,4,8},13],IntegerQ] (* _Harvey P. Dale_, Sep 08 2024 *)

%o (PARI) is_A202170(n)=!setminus(Set(Vec(Str(n^2))),Vec("048"))

%o (Magma) [ n: n in [0..10^6 by 2] | Set(Intseq(n^2)) subset [0,4,8] ]; // _Bruno Berselli_, Dec 19 2011

%Y Cf. A030097, A058441.

%Y Includes 2*A136808.

%K nonn,base

%O 1,2

%A _M. F. Hasler_, Dec 13 2011

%E More terms from _Robert Israel_, Jul 17 2018