cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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).

Original entry on oeis.org

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, 8, 27, 31, 28, 37, 29, 38, 32, 41, 33, 42, 34, 35, 40, 36, 45, 39, 48, 43, 52, 44, 53, 46, 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
Offset: 1

Views

Author

Eric Angelini and M. F. Hasler, Nov 01 2014

Keywords

Crossrefs

Programs

  • Maple
    N:= 200: # to get the first N terms
      S:= {}:
      m:= 2:
    a[1]:= 1:
    xnext:= proc(x)
        local j, Sc;
        Sc:= select(`>`,S,x);
        if Sc <> {} then min(Sc)
        elif x < m then m
        else x+1
        fi
    end proc:
    for n from 2 to N do
      adigs:= convert(convert(a[n-1],base,10),set);
      bdigs:= {$0..8} intersect map(`-`,adigs,1);
      c:= 0;
      do
        c:= xnext(c);
        if convert(convert(c,base,10),set) intersect bdigs <> {} then
           if member(c,S) then S:= S minus {c}
           else
             S:= S union {$m .. c-1};
             m:= c + 1;
           fi;
           a[n]:= c;
           break
        fi
      od;
    od:
    seq(a[n],n=1..N); # Robert Israel, Nov 03 2014
  • 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! */