login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A249585 Lexicographically earliest permutation of the positive integers such that a(n+1) has at least one digit which increased by 1 is a digit of a(n). 3

%I

%S 1,10,20,11,30,2,12,13,21,14,3,22,15,4,23,16,5,24,17,6,25,18,7,26,19,

%T 8,27,31,28,37,29,38,32,41,33,42,34,35,40,36,45,39,48,43,52,44,53,46,

%U 50,47,56,49,58,54,63,51,60,55,64,57,61,59,68,65,74,62,71,66,75,67,69,78,70,76,85,72,81,73,82,77,86,79,80,87,96,83,92,84,93,88

%N Lexicographically earliest permutation of the positive integers such that a(n+1) has at least one digit which increased by 1 is a digit of a(n).

%H Robert Israel, <a href="/A249585/b249585.txt">Table of n, a(n) for n = 1..10000</a>

%H E. Angelini, <a href="http://list.seqfan.eu/pipermail/seqfan/2014-November/013903.html">Downgrade one of the digits of a(n-1)</a>, Nov 01 2014.

%p N:= 200: # to get the first N terms

%p S:= {}:

%p m:= 2:

%p a[1]:= 1:

%p xnext:= proc(x)

%p local j, Sc;

%p Sc:= select(`>`,S,x);

%p if Sc <> {} then min(Sc)

%p elif x < m then m

%p else x+1

%p fi

%p end proc:

%p for n from 2 to N do

%p adigs:= convert(convert(a[n-1],base,10),set);

%p bdigs:= {$0..8} intersect map(`-`,adigs,1);

%p c:= 0;

%p do

%p c:= xnext(c);

%p if convert(convert(c,base,10),set) intersect bdigs <> {} then

%p if member(c,S) then S:= S minus {c}

%p else

%p S:= S union {$m .. c-1};

%p m:= c + 1;

%p fi;

%p a[n]:= c;

%p break

%p fi

%p od;

%p od:

%p seq(a[n],n=1..N); # _Robert Israel_, Nov 03 2014

%o (PARI) A249585(n,show=0,a=1,u=[])={for(i=2,n, show&&print1(a","); u=setunion(u,Set(a)); D=Set(apply(d->d-1,digits(a))); while(setsearch(u,1+m=vecmin(u)),u=setminus(u,Set(m))); for(m=m+1,9e9,!setsearch(u,m)&&#setintersect(D,Set(digits(m))) &&(a=m)&&break));a} /* Using a more natural and simpler until() loop is 10x slower! */

%Y Cf. A249591, A067581.

%K nonn,base

%O 1,2

%A _Eric Angelini_ and _M. F. Hasler_, Nov 01 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 02:19 EDT 2021. Contains 343105 sequences. (Running on oeis4.)