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 at most once and the operators +, -, *, /, where intermediate subexpressions must be integers.
3

%I #19 Jan 31 2023 08:48:39

%S 1,2,4,11,34,152,1007,7335,85761,812767

%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 at most once and the operators +, -, *, /, where intermediate subexpressions must be integers.

%C a(n+1) > 2*a(n) + 2 for n > 3 since a(n) may be added to every number possible at the previous step (at least 1..a(n)-1) and a(n), 2*a(n), 2*a(n)+1, and 2*(a(n)+1) are also present. - _Michael S. Branicky_, Jan 30 2023

%H Gilles Bannay, <a href="https://web.archive.org/web/20061201125224/http://gilles.bannay.free.fr/jeux_us.html">Countdown Problem</a>

%H <a href="/index/Fo#4x4">Index entries for similar sequences</a>

%e a(4)=11 because we can write 4+1=5, 4+2=6, 4+2+1=7, 4*2=8, 4*2+1=9, (4+1)*2=10 by using 1, 2 and 4 but we cannot do the same thing for 11.

%o (Python)

%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 and b%a==0: allowed.append(b//a)

%o if b!=0 and a%b==0: allowed.append(a//b)

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

%o reach.update(allowed)

%o k = 1

%o while k in reach: k += 1

%o return k

%o alst = [1]

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

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

%Y Cf. A060315, A217043 (allows intermediate fractions).

%K hard,more,nonn

%O 1,2

%A Koksal Karakus (karakusk(AT)hotmail.com), May 27 2002