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-3 of 3 results.

A342602 Number of solutions to 1 +-* 2 +-* 3 +-* ... +-* n = 0.

Original entry on oeis.org

0, 0, 1, 1, 1, 4, 6, 14, 29, 63, 129, 300, 756, 1677, 4134, 9525, 22841, 57175, 141819, 354992, 882420, 2218078, 5588989, 14173217, 35918542
Offset: 1

Views

Author

Scott R. Shannon, Mar 27 2021

Keywords

Comments

Normal operator precedence is followed, so multiplication is performed before addition or subtraction. Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 3.
The author thanks Ursula Ponting for useful discussions.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 1 as 1 * 2 - 3 - 4 + 5 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(6) = 4. The solutions, all of which use multiplication, are
         1 + 2 * 3 + 4 - 5 - 6 = 0,
         1 - 2 + 3 * 4 - 5 - 6 = 0,
         1 - 2 * 3 + 4 - 5 + 6 = 0,
         1 * 2 + 3 - 4 + 5 - 6 = 0.
a(10) = 63. An example solution is
         1 - 2 * 3 * 4 - 5 - 6 - 7 * 8 + 9 * 10 = 0.
a(20) = 354992. An example solution is
         1 * 2 * 3 * 4 * 5 * 6 * 7 + 8 * 9 + 10 * 11 - 12 * 13 + 14 * 15
             - 16 * 17 * 18 - 19 * 20 = 0
  which includes thirteen multiplications.
		

Crossrefs

Cf. A342804 (using +-*/), A342995 (using +-/), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","*"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    def a(n):
      nn = [str(i) for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-*", repeat=n-1))
    print([a(n) for n in range(1, 14)]) # Michael S. Branicky, Apr 02 2021

A342995 Number of solutions to 1 +-/ 2 +-/ 3 +-/ ... +-/ n = 0.

Original entry on oeis.org

0, 0, 1, 1, 0, 1, 4, 8, 0, 3, 37, 80, 6, 17, 461, 868, 190, 364, 5570, 11342, 3993, 7307, 78644
Offset: 1

Views

Author

Scott R. Shannon, Apr 01 2021

Keywords

Comments

Normal operator precedence is followed, so division is performed before addition or subtraction. Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 10.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 0, as in A058377.
a(6) = 1 as 1 - 2 / 3 / 4 - 5 / 6 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(8) = 8. Seven of the solutions involve just addition and subtraction, matching those in A058377, but one additional solution exists using division:
        1 / 2 / 3 / 4 + 5 / 6 - 7 / 8 = 0.
a(10) = 3. All three solutions require division:
        1 + 2 / 3 / 4 + 5 / 6 + 7 - 8 + 9 - 10 = 0,
        1 - 2 / 3 / 4 - 5 / 6 + 7 - 8 - 9 + 10 = 0,
        1 - 2 / 3 / 4 - 5 / 6 - 7 + 8 + 9 - 10 = 0.
a(15) = 461. Of these, 361 use only addition and subtraction, the other 100 also require division. One example of the latter is
        1 / 2 / 3 / 4 - 5 - 6 - 7 / 8 + 9 / 10 + 11 + 12 - 13 + 14 / 15 = 0.
a(20) = 11342. An example solution is
        1 / 2 / 3 - 4 / 5 / 6 + 7 / 8 / 9 + 10 + 11 / 12 - 13 + 14 / 15 / 16
             + 17 / 18 + 19 / 20 = 0
  which sums seven fractions that include eleven divisions.
		

Crossrefs

Cf. A342804 (using +-*/), A342602 (using +-*), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","/"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    from fractions import Fraction
    def a(n):
      nn = ["Fraction("+str(i)+", 1)" for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-/", repeat=n-1))
    print([a(n) for n in range(1, 11)]) # Michael S. Branicky, Apr 02 2021

A363802 Numbers whose digits can be interposed with one or more of the arithmetic operators +, -, *, /, with no parentheses or concatenation, to yield 10 as the result.

Original entry on oeis.org

19, 25, 28, 37, 46, 52, 55, 64, 73, 82, 91, 109, 118, 119, 125, 127, 128, 133, 136, 137, 145, 146, 152, 154, 155, 163, 164, 172, 173, 181, 182, 190, 191, 208, 215, 217, 218, 219, 224, 226, 229, 234, 235, 242, 244, 250, 251, 253, 262, 271, 274, 280, 281, 286, 291, 298, 307
Offset: 1

Views

Author

Evan Gillard, Jun 23 2023

Keywords

Comments

This sequence is a variant of a "game" you can play using the numbers on train carriages (usually 4 digits in Australia's case), ignoring prefixed zeros, preventing re-ordering of the digits and allowing only addition, subtraction, multiplication and division.
No parentheses or concatenation are allowed and expressions follow operator precedence (*/) then (+-), and left to right within the same level of precedence: "2 + 3 * 2 / 6" is 2 + ((3*2)/6) = 2 + 1 = 3.
Infinite since A052224 is a subsequence. - Michael S. Branicky, Jun 24 2023

Examples

			1 + 9 = 2 + 8 = 1 * 9 + 1 = 2 * 9 - 8 = 10 so 19, 28, 191 and 298 are terms.
110 is not a term even though 1 * 10 = 10 since concatenation is disallowed.
		

Crossrefs

Supersequence of A052224.

Programs

  • Python
    from itertools import product
    from fractions import Fraction
    def is_A363802(n):
        s = [f"Fraction({d}, 1)" for d in str(n)]
        for ops in product("+-*/", repeat=len(s)-1):
            try: v = eval("".join(sum(zip(ops, s[1:]), (s[0],))))
            except: v = None
            if v == 10: return True
        return False
    # Evan Gillard and Michael S. Branicky, Jun 23 2023
Showing 1-3 of 3 results.