%I #17 Feb 21 2014 03:17:02
%S 497375,539019,543447,586476,589629,601575,646479,858609,895688,959097
%N Numbers n such that the union of the decimal digits of n^2 and n^3 contains every decimal digit exactly three times.
%C The sequence is finite (proof in reference). There are exactly 10 numbers.
%D J.-M. De Koninck - Armel Mercier, 1001 problemes en theorie classique des nombres, exercise number 255, p. 184, Ellipses, Paris 2004.
%e 497375 is in the sequence because: 497375^2 = 247381890625; 497375^3 = 123041567849609375; and the union of the digits is:{247381890625123041567849609375} contains 3 digits "0", 3 digits "1", 3 digits "2", ..., 3 digits "9".
%p with(numtheory): U:=array(1..30) :c:=0:for i from 300000 to 1000000 do: n2:=i^2:n3:=i^3:l2:=length(n2):l3:=length(n3):if l2=30-l3 then n0:=n2:nn0:=n3:for m from 1 to l2 do:q2:=n0:u2:=irem(q2, 10):v2:=iquo(q2, 10):n0:=v2 : U[m]:=u2:od:for mm from l2+1 to 30 do:q3:=nn0:u3:=irem(q3, 10):v3:=iquo(q3, 10):nn0:=v3 : U[mm]:=u3: od: s1:=0:s2:=0:s3:=0:for j from 1 to 30 do:s1:=s1+U[j]^3:s2:=s2+U[j]^7:od:if s1=6075 and s2=24241275 then c:=c+1:printf(`%d, `, i): else fi:else fi:od: print(c):
%K nonn,base,fini,full
%O 1,1
%A _Michel Lagneau_, Jan 01 2011