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.

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

This page as a plain text file.
%I A342602 #45 Apr 04 2021 01:02:23
%S A342602 0,0,1,1,1,4,6,14,29,63,129,300,756,1677,4134,9525,22841,57175,141819,
%T A342602 354992,882420,2218078,5588989,14173217,35918542
%N A342602 Number of solutions to 1 +-* 2 +-* 3 +-* ... +-* n = 0.
%C A342602 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.
%C A342602 The author thanks Ursula Ponting for useful discussions.
%e A342602 a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
%e A342602 a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
%e A342602 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.
%e A342602 a(6) = 4. The solutions, all of which use multiplication, are
%e A342602          1 + 2 * 3 + 4 - 5 - 6 = 0,
%e A342602          1 - 2 + 3 * 4 - 5 - 6 = 0,
%e A342602          1 - 2 * 3 + 4 - 5 + 6 = 0,
%e A342602          1 * 2 + 3 - 4 + 5 - 6 = 0.
%e A342602 a(10) = 63. An example solution is
%e A342602          1 - 2 * 3 * 4 - 5 - 6 - 7 * 8 + 9 * 10 = 0.
%e A342602 a(20) = 354992. An example solution is
%e A342602          1 * 2 * 3 * 4 * 5 * 6 * 7 + 8 * 9 + 10 * 11 - 12 * 13 + 14 * 15
%e A342602              - 16 * 17 * 18 - 19 * 20 = 0
%e A342602   which includes thirteen multiplications.
%t A342602 Table[Length@Select[Tuples[{"+","-","*"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* _Giorgos Kalogeropoulos_, Apr 02 2021 *)
%o A342602 (Python)
%o A342602 from itertools import product
%o A342602 def a(n):
%o A342602   nn = [str(i) for i in range(1, n+1)]
%o A342602   return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-*", repeat=n-1))
%o A342602 print([a(n) for n in range(1, 14)]) # _Michael S. Branicky_, Apr 02 2021
%Y A342602 Cf. A342804 (using +-*/), A342995 (using +-/), A058377 (using +-), A063865, A000217, A025591, A161943.
%K A342602 nonn,more
%O A342602 1,6
%A A342602 _Scott R. Shannon_, Mar 27 2021