login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 


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 +, -, *, / and accepting fractional intermediate results.
2

%I #24 Dec 29 2022 06:46:17

%S 1,2,4,11,34,152,1143,8285,98863,1211572

%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 +, -, *, / and accepting fractional intermediate results.

%H Gilles Bannay, <a href="https://web.archive.org/web/20061201125224/http://gilles.bannay.free.fr/jeux_us.html">Countdown Problem</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 construct 11 this way.

%e a(7)=1143 because 1142 = (152+((34-4)*(11*(2+1)))), and 1143 is impossible.

%e a(7) is not 1007 because it can be constructed as 1007 = 152*(11-(34+1)/(4*2)); the fractional intermediate result 35/8, for example, is accepted in the composition.

%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 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, 6)]

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

%Y Cf. A060315, A071115 (disallows intermediate fractions).

%K nonn,more

%O 1,2

%A _Clément Morelle_, Sep 25 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 22 14:59 EDT 2024. Contains 376114 sequences. (Running on oeis4.)