A342804 Number of solutions to 1 +-*/ 2 +-*/ 3 +-*/ ... +-*/ n = 0.
0, 0, 1, 1, 1, 5, 8, 18, 39, 91, 185, 460, 1051, 2526, 6280, 15645, 35516, 93765, 225989, 611503
Offset: 1
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) = 5. The solutions, all of which use multiplication or division, 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, 1 - 2 / 3 / 4 - 5 / 6 = 0. The last solution is the first that uses division. a(7) = 8. Six solutions use just addition, division and multiplication. The other two are 1 + 2 - 3 * 4 * 5 / 6 + 7 = 0, 1 / 2 * 3 * 4 - 5 + 6 - 7 = 0. a(15) = 6280. An example solution is 1 / 2 / 3 / 4 * 5 * 6 - 7 - 8 + 9 / 10 + 11 / 12 * 13 + 14 / 15 = 0 which includes four fractions that sum to 15, which is balanced by - 7 - 8. a(20) = 611503. 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 five fractions that include fourteen divisions.
Crossrefs
Programs
-
Mathematica
Table[Length@Select[Tuples[{"+","-","*","/"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,9}] (* 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, 10)]) # Michael S. Branicky, Apr 02 2021
Comments