A342995 Number of solutions to 1 +-/ 2 +-/ 3 +-/ ... +-/ n = 0.
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
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
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
Comments