login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A276633
a(n) = smallest integer not yet in the sequence with no digits in common with a(n-1) and a(n-2); a(0)=0, a(1)=1.
15
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 33, 11, 20, 34, 15, 26, 30, 14, 25, 36, 17, 24, 35, 16, 27, 38, 19, 40, 23, 18, 44, 29, 13, 45, 28, 31, 46, 50, 12, 37, 48, 21, 39, 47, 51, 32, 49, 55, 60, 41, 52, 63, 70, 42, 53, 61, 72, 43, 56, 71, 80, 54, 62, 73, 58, 64, 77, 59, 66, 74, 81, 65, 79
OFFSET
0,3
COMMENTS
The sequence is not a permutation of the positive integers. E.g., 123456789 and 1023456789 (the smallest pandigital number) are not members.
Numbers n such that a(n)=n: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 52, 147, 1619, 6140, ...
The sequence is infinite, since all digits in a(n-3) are allowed in a(n). - Robert Israel, Sep 20 2016
LINKS
Zak Seidov and David A. Corneth, Table of n, a(n) for n = 0..19999 (First 2001 terms from Zak Seidov).
EXAMPLE
From David A. Corneth, Sep 22 2016: (Start)
Each number can consist of 2^10-1 sets of distinct digits, i.e., classes. For example, 21132 is in the class {1, 2, 3}. We don't include a number without digits. For this sequence, we can also exclude numbers with only the digit 0. This leaves 1022 classes. We create a list with a place for each class containing the least number from that class not already in the sequence.
To illustrate the algorithm used to create the current b-file, we'll (for brevity) assume we've already calculated all terms for n = 1 to 100 and that we already know which classes will be used to compute the next 10 terms, for n = 101 to 110.
These classes are: {0, 1}, {2, 3}, {5, 9}, {7, 9}, {8, 9}, {0, 1, 6}, {0, 1, 7}, {2, 2, 2} and {2, 2, 4} having the values 110, 223, 95, 97, 89, 106, 107, 222 and 224. a(99) = 104 and a(100) = 88, so from those values we may only choose from {223, 95, 97 and 222}. The least value in the list is 95. Therefore, a(101) = 95. The number for the class is now replaced with the next larger number having digits {5, 9} (=A276769(95)), being 559.
(One may see that in the example I only listed 9 classes. Class {8, 9} occurs twice in the example; a(104) = 89 and a(107) = 98.)
From a list of computed values up to some n, the values for classes may be updated to compute further. E.g., to compute a(20000), one may use the b-file to find the least number not already in the sequence for each class and then proceed from a(19998) and a(19999), etc. (End)
MAPLE
N:= 10^3: # to get all terms before the first > N
for R in combinat:-powerset({$0..9}) minus {{}, {$0..9}} do
Lastused[R]:= [];
MR[R]:= Array[0..9];
for i from 1 to nops(R) do MR[R][R[i]]:= i od:
od:
A[0]:= 0: A[1]:= 1:
S:= {0, 1}:
for n from 2 to N do
R:= {$0..9} minus (convert(convert(A[n-1], base, 10), set) union convert(convert(A[n-2], base, 10), set));
L:= Lastused[R];
x:= 0;
while member(x, S) do
for d from 1 do
if d > nops(L) then
if R[1] = 0 then L:= [op(L), R[2]] else L:= [op(L), R[1]] fi;
break
elif L[d] < R[-1] then
L[d]:= R[MR[R][L[d]]+1]; break
else
L[d]:= R[1];
fi
od;
x:= add(L[j]*10^(j-1), j=1..nops(L));
od;
A[n]:= x;
S:= S union {x};
Lastused[R] := L;
od:
seq(A[i], i=0..N); # Robert Israel, Sep 20 2016
MATHEMATICA
s={0, 1}; Do[a=s[[-2]]; b=s[[-1]]; n=2; idab=Union[IntegerDigits[a], IntegerDigits[b]]; While[MemberQ[s, n]|| Intersection[idab, IntegerDigits[n]]!={}, n++]; AppendTo[s, n], {100}]; s
PROG
(Python)
from itertools import count, islice, product as P
def only(s, D=1): # numbers with >= D digits only from s
yield from (int("".join(p)) for d in count(D) for p in P(s, repeat=d))
def agen(): # generator of terms
aset, an1, an, minan = {0, 1}, 0, 1, 2
yield from [0, 1]
while True:
an1, an, s = an, minan, set(str(an) + str(an1))
use = "".join(c for c in "0123456789" if c not in s)
for an in only(use, D=len(str(minan))):
if an not in aset: break
aset.add(an)
yield an
while minan in aset: minan += 1
print(list(islice(agen(), 75))) # Michael S. Branicky, Jun 30 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Zak Seidov and Eric Angelini, Sep 08 2016
STATUS
approved