%I #23 Dec 13 2022 16:27:36
%S 10,100,100,100,100,100,100,100,100,89,99,1000,1000,818,1000,1000,
%T 1000,1000,168,90,100,1000,1000,1000,1000,727,336,247,1000,899,100,
%U 1000,1000,1000,1000,1000,326,636,1000,899,100,1000,1000,1000,1000,405,1000,227,1000,545,100,1000,1000,1000,450,494,1000,1000,1000,899
%N Least positive integer N such that n+N has the same digits as n and N together (without counting repetitions).
%C Such an N always exists since 10^(1 + number of digits of n) satisfies the property.
%C a(n) = 1 for almost all n (in the sense of natural density). - _Charles R Greathouse IV_, Nov 15 2022
%C What is the largest number in this sequence? It is somewhere between a(9911111111) = 302345678 and 203456789111111111. - _Charles R Greathouse IV_, Dec 09 2022
%H Robert Israel, <a href="/A266798/b266798.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) <= 10^(1 + number of digits of n).
%F a(n) <= 203456789111111111 < 2.04 * 10^17. (This can probably be improved by a few orders of magnitude.) - _Charles R Greathouse IV_, Nov 15 2022
%p digs:= proc(n) option remember;
%p local t;
%p t:= n mod 10;
%p if n < 10 then {t}
%p else {t} union procname((n-t)/10)
%p fi;
%p end proc:
%p f:= proc(n)
%p local k,Ln;
%p Ln:= digs(n);
%p for k from 1 do
%p if Ln union digs(k) = digs(n+k) then return k fi
%p od
%p end proc:
%p seq(f(n),n=0..100); # _Robert Israel_, Jan 03 2016
%o (PARI) a(n,d=digits(n),L=10^(1+#d))=for(k=1,L,Set(digits(k+n))==Set(concat(d,digits(k)))&&return(k))
%o (Python)
%o from itertools import count
%o def a(n):
%o digs = set(str(n))
%o return next(N for N in count(1) if digs | set(str(N)) == set(str(n+N)))
%o print([a(n) for n in range(60)]) # _Michael S. Branicky_, Nov 15 2022
%Y Cf. A266586, A266578.
%K nonn,base
%O 0,1
%A _M. F. Hasler_, Jan 01 2016
|