A292510 a(n) = smallest k >= 1 such that {1, p(n,2), p(n,3), ..., p(n,k)} can be partitioned into two sets with equal sums, where p(n,m) is m-th n-gonal number.
4, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
Offset: 3
Keywords
Examples
n = 3 1+3+6 = 10 n = 4 1+4+16+49 = 9+25+36 (= 70 = 28*4-42) n = 5 1+5+22+35 = 12+51 (=63) n = 6 1+6+28+91 = 15+45+66 (= 126 = 28*6-42)
Links
- Wikipedia, Polygonal number
Programs
-
Ruby
def f(k, n) n * ((k - 2) * n - k + 4) / 2 end def A(k, n) ary = [1] s_ary = [0] (1..n).each{|i| s_ary << s_ary[-1] + f(k, i)} m = s_ary[-1] a = Array.new(m + 1){0} a[0] = 1 (1..n).each{|i| b = a.clone (0..[s_ary[i - 1], m - f(k, i)].min).each{|j| b[j + f(k, i)] += a[j]} a = b s_ary[i] % 2 == 0 ? ary << a[s_ary[i] / 2] : ary << 0 } ary end def B(n) i = 1 while A(n, i)[-1] == 0 i += 1 end i end def A292510(n) (3..n).map{|i| B(i)} end p A292510(100)
Formula
p(n,1) + p(n,2) + p(n,4) + p(n,7) = p(n,3) + p(n,5) + p(n,6) (= 28*n-42). So a(n) <= 7.
Comments