cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A071115 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.

Original entry on oeis.org

1, 2, 4, 11, 34, 152, 1007, 7335, 85761, 812767
Offset: 1

Views

Author

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

Keywords

Comments

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

Examples

			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.
		

Crossrefs

Cf. A060315, A217043 (allows intermediate fractions).

Programs

  • 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]}
        reach = set(v)
        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)
                                    reach.update(allowed)
        k = 1
        while k in reach: k += 1
        return k
    alst = [1]
    [alst.append(a(n, alst)) for n in range(1, 8)]
    print(alst) # Michael S. Branicky, Jul 01 2022

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

Original entry on oeis.org

1, 2, 4, 11, 34, 152, 1079, 6610, 93221
Offset: 1

Views

Author

Rainer Rosenthal and Hugo Pfoertner, Nov 01 2022

Keywords

Crossrefs

Programs

  • Python
    from fractions import Fraction
    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]}
        #reach = set(v)
        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: allowed.append(Fraction(b, a))
                                    if b!=0: allowed.append(Fraction(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, 6)]
    print(alst) # Michael S. Branicky, Nov 01 2022

Extensions

a(9) from Michael S. Branicky, Nov 10 2022
Showing 1-2 of 2 results.