login
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 +, -, *, /.
1

%I #11 Nov 10 2022 12:35:59

%S 1,2,4,11,34,152,1079,6610,93221

%N 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 +, -, *, /.

%o (Python)

%o from fractions import Fraction

%o def a(n, v):

%o R = dict() # index of each reachable subset is [card(s)-1][s]

%o for i in range(n): R[i] = dict()

%o for i in range(n): R[0][(v[i], )] = {v[i]}

%o #reach = set(v)

%o for j in range(1, n):

%o for i in range((j+1)//2):

%o for s1 in R[i]:

%o for s2 in R[j-1-i]:

%o if set(s1) & set(s2) == set():

%o s12 = tuple(sorted(set(s1) | set(s2)))

%o if s12 not in R[len(s12)-1]:

%o R[len(s12)-1][s12] = set()

%o for a in R[i][s1]:

%o for b in R[j-1-i][s2]:

%o allowed = [a+b, a*b, a-b, b-a]

%o if a!=0: allowed.append(Fraction(b, a))

%o if b!=0: allowed.append(Fraction(a, b))

%o R[len(s12)-1][s12].update(allowed)

%o k = 1

%o while k in R[n-1][tuple(v)]: k += 1

%o return k

%o alst = [1]

%o [alst.append(a(n, alst)) for n in range(1, 6)]

%o print(alst) # _Michael S. Branicky_, Nov 01 2022

%Y Cf. A071115, A217043, A358075.

%K nonn,hard,more

%O 1,2

%A _Rainer Rosenthal_ and _Hugo Pfoertner_, Nov 01 2022

%E a(9) from _Michael S. Branicky_, Nov 10 2022