login
Numbers n such that each decimal digit of n is equal to the difference of at least two other digits of n.
4

%I #9 Oct 17 2021 12:31:10

%S 101,110,202,220,303,330,404,440,505,550,606,660,707,770,808,880,909,

%T 990,1001,1010,1011,1100,1101,1110,2002,2020,2022,2200,2202,2220,3003,

%U 3030,3033,3300,3303,3330,4004,4040,4044,4400,4404,4440,5005,5050,5055,5500

%N Numbers n such that each decimal digit of n is equal to the difference of at least two other digits of n.

%C Let x(1)x(2)... x(q-1)x(q) denote the decimal expansion of a number n. The sequence lists the numbers n such that, for all index i, x(i) = x(j) - x(k) for some index j and k.

%C The sequence is infinite because a(n)*10^m for all integers m is also in the sequence.

%C All numbers of the sequence contain at least two identical decimal digits. a(n) contains at least one decimal digit equal to zero. The number

%C 12345678909 is the smallest element of the sequence containing 10 distinct digits.

%C The prime numbers of the sequence are 101, 10111, 10133, 10177,...

%C The squares of the sequence are 59049, 60516, 91809, 130321,...

%H Michel Lagneau, <a href="/A255966/b255966.txt">Table of n, a(n) for n = 1..10000</a>

%e 34707 is in the sequence because 3=7-4, 4=7-3,7=7-0 and 0=7-7.

%p with(numtheory):

%p for n from 100 to 10000 do:

%p x:=convert(n,base,10):n1:=nops(x):c:=0:T:=array(1..n1-1):

%p for nn from 1 to n1 do:

%p z:=x[nn]:

%p k:=0:

%p for j from 1 to n1 do:

%p if nn<>j

%p then

%p k:=k+1:T[k]:=x[j]:

%p else

%p fi:

%p od:

%p ii:=0:

%p for a from 1 to n1-1 while(ii=0) do:

%p for b from a+1 to n1-1 while(ii=0) do:

%p if z=abs(T[a]-T[b]) then ii:=1:c:=c+1:

%p else

%p fi:

%p od:od:

%p od:

%p if c=n1 then printf(`%d, `,n):

%p else

%p fi:

%p od:

%Y Cf. A255892, A255893, A255917.

%K nonn,base

%O 1,1

%A _Michel Lagneau_, Mar 12 2015

%E Comments corrected by _Harvey P. Dale_, Oct 17 2021