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

A358075
a(1) = 1; a(n+1) is the smallest integer > 0 that cannot be obtained from the integers {a(1), ..., a(n)} using each number exactly once and the operators +, -, *, /, where intermediate subexpressions must be integers.
1
1, 2, 4, 11, 34, 152, 1007, 6703, 56837, 766478
OFFSET
1,2
COMMENTS
A variation of sequence A071115: terms are used "exactly once" instead of "at most once". First difference is a(8) = 6703 < 7335 = A071115(8).
EXAMPLE
All positive numbers up to 151 can be computed from the first 5 terms 1, 2, 4, 11, 34; e.g., 105 = (1 + 4) * (34 - 11 - 2). All terms are used, and each term is used only once.
There is no such formula for 152, so a(6) = 152.
MAPLE
restart: with(combinat):
# generate numbers from set s
GEN := proc(s) option remember;
local erg, X, Y, x, y, i, a, b;
if nops(s) < 2 then
return s;
fi;
erg := {};
for i to nops(s)/2 do
for a in choose(s, i) do
b := s minus a;
X := procname(a);
Y := procname(b);
for x in X do
for y in Y do
erg := erg union {x+y};
if x < y then
erg := erg union {y-x};
elif x > y then
erg := erg union {x-y};
fi;
erg := erg union {x*y};
if type(x/y, integer) then
erg := erg union {x/y};
elif type(y/x, integer) then
erg := erg union {y/x};
fi;
od;
od;
od;
od;
return erg;
end:
# minimal excluded number (not in set s)
MEX := proc(s)
local i;
for i to infinity do
if not member(i, s) then
return i;
fi;
od;
end:
MaxIndex := 8;
a := array(1..MaxIndex):
w := {}:
for n to MaxIndex do
a[n] := MEX(GEN(w));
w := w union {a[n]};
od:
seq(a[n], n=1..MaxIndex);
PROG
(Python)
def a(n, v):
R = dict() # index of each reachable subset is [card(s)-1][s]
for i in range(n): R[i] = dict()
for i in range(n): R[0][(v[i], )] = {v[i]}
for j in range(1, n):
for i in range((j+1)//2):
for s1 in R[i]:
for s2 in R[j-1-i]:
if set(s1) & set(s2) == set():
s12 = tuple(sorted(set(s1) | set(s2)))
if s12 not in R[len(s12)-1]:
R[len(s12)-1][s12] = set()
for a in R[i][s1]:
for b in R[j-1-i][s2]:
allowed = [a+b, a*b, a-b, b-a]
if a!=0 and b%a==0: allowed.append(b//a)
if b!=0 and a%b==0: allowed.append(a//b)
R[len(s12)-1][s12].update(allowed)
k = 1
while k in R[n-1][tuple(v)]: k += 1
return k
alst = [1]
[alst.append(a(n, alst)) for n in range(1, 8)]
print(alst) # Michael S. Branicky, Oct 30 2022
CROSSREFS
Sequence in context: A362638 A344489 A238425 * A071115 A357891 A217043
KEYWORD
nonn,hard,more
AUTHOR
Rainer Rosenthal, Oct 29 2022
EXTENSIONS
a(9) from Michael S. Branicky, Oct 30 2022
a(10) from Michael S. Branicky, Nov 07 2022
STATUS
approved