login
If n <= 1 then n else smallest number having in decimal representation exactly one common digit with its predecessor but none with its pre-predecessor.
1

%I #12 Mar 30 2024 04:36:25

%S 0,1,12,20,30,31,41,42,52,53,63,64,74,75,85,86,96,97,107,122,233,300,

%T 401,422,523,560,611,712,730,804,811,912,930,3444,4111,5001,5222,6233,

%U 6400,7011,7222,8233,8400,9011,9222,23333,30000,40111,42222,52333,56000

%N If n <= 1 then n else smallest number having in decimal representation exactly one common digit with its predecessor but none with its pre-predecessor.

%C Apparently the rules demand that a(n)>a(n-1) and that the "common" digit between a(n) and a(n-1) must appear only once in a(n). [Otherwise after 107 would follow 111.] - _R. J. Mathar_, May 05 2023

%H R. J. Mathar, <a href="/A107277/b107277.txt">Table of n, a(n) for n = 0..73</a>

%e a(8)=52 and a(9)=53. a(10) cannot be any in the range 54..59 because these share the digit 5 with a(8) and a(9). a(10) cannot be in the range 60..62 because these do not have a common digit with 53. So a(10)=63. - _R. J. Mathar_, May 05 2023

%p freq := proc(L,n)

%p local a;

%p a := 0 ;

%p for i from 1 to nops(L) do

%p if op(i,L) = n then

%p a := a+1 ;

%p end if ;

%p end do:

%p a ;

%p end proc:

%p A107277 := proc(n)

%p option remember ;

%p local a,dgsa,pre,pre2,dgspre,dgspre2,cdig;

%p if n <= 1 then

%p n ;

%p elif n =2 then

%p 12 ;

%p else

%p for a from procname(n-1)+1 do

%p dgsa := convert(convert(a,base,10),set) ;

%p pre2 := procname(n-2) ;

%p dgspre2 := convert(convert(pre2,base,10),set) ;

%p if dgspre2 intersect dgsa = {} then

%p pre := procname(n-1) ;

%p dgspre := convert(convert(pre,base,10),set) ;

%p cdig := dgsa intersect dgspre ;

%p if nops(cdig) = 1 then

%p dgsa := convert(a,base,10) ;

%p if freq(dgsa,op(cdig)) = 1 then

%p return a;

%p end if;

%p end if;

%p end if ;

%p end do:

%p end if;

%p end proc:

%p seq(A107277(n),n=0..60) ; # _R. J. Mathar_, May 05 2023

%K nonn,base

%O 0,3

%A _Reinhard Zumkeller_, May 19 2005