A300190 Number of solutions to 1 +- 2 +- 3 +- ... +- n == 0 (mod n).
1, 0, 2, 4, 4, 0, 10, 32, 30, 0, 94, 344, 316, 0, 1096, 4096, 3856, 0, 13798, 52432, 49940, 0, 182362, 699072, 671092, 0, 2485534, 9586984, 9256396, 0, 34636834, 134217728, 130150588, 0, 490853416, 1908874584, 1857283156, 0, 7048151672, 27487790720
Offset: 1
Keywords
Examples
Solutions for n = 7: -------------------------- 1 +2 +3 +4 +5 +6 +7 = 28. 1 +2 +3 +4 +5 +6 -7 = 14. 1 +2 -3 +4 -5 -6 +7 = 0. 1 +2 -3 +4 -5 -6 -7 = -14. 1 +2 -3 -4 +5 +6 +7 = 14. 1 +2 -3 -4 +5 +6 -7 = 0. 1 -2 +3 +4 -5 +6 +7 = 14. 1 -2 +3 +4 -5 +6 -7 = 0. 1 -2 -3 -4 -5 +6 +7 = 0. 1 -2 -3 -4 -5 +6 -7 = -14.
Links
- Seiichi Manyama, Table of n, a(n) for n = 1..3334 (terms 1..1000 from Alois P. Heinz)
Crossrefs
Programs
-
Maple
b:= proc(n, i, m) option remember; `if`(i=0, `if`(n=0, 1, 0), add(b(irem(n+j, m), i-1, m), j=[i, m-i])) end: a:= n-> b(0, n-1, n): seq(a(n), n=1..60); # Alois P. Heinz, Mar 01 2018
-
Mathematica
b[n_, i_, m_] := b[n, i, m] = If[i == 0, If[n == 0, 1, 0], Sum[b[Mod[n + j, m], i - 1, m], {j, {i, m - i}}]]; a[n_] := b[0, n - 1, n]; Array[a, 60] (* Jean-François Alcover, Apr 29 2020, after Alois P. Heinz *)
-
Ruby
def A(n) ary = [1] + Array.new(n - 1, 0) (1..n).each{|i| i1 = 2 * i a = ary.clone (0..n - 1).each{|j| a[(j + i1) % n] += ary[j]} ary = a } ary[(n * (n + 1) / 2) % n] / 2 end def A300190(n) (1..n).map{|i| A(i)} end p A300190(100)
Comments