login
A337785
Number of addition triangles whose sum is n (version 1).
2
1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 2, 6, 1, 9, 1, 9, 4, 9, 3, 14, 2, 14, 6, 14, 5, 21, 4, 19, 10, 21, 8, 27, 6, 29, 16, 25, 12, 38, 14, 33, 19, 37, 22, 46, 14, 47, 33, 45, 22, 59, 29, 59, 35, 56, 40, 74, 34, 68, 53, 72, 47, 90, 47, 88, 63, 88, 64, 105, 59, 108, 84, 106, 75, 130, 81, 125, 99, 128, 103, 147
OFFSET
1,4
COMMENTS
An addition triangle has any set of positive numbers as base; other rows are formed by adding pairs of adjacent numbers.
Reversing the base counts as a different triangle.
LINKS
EXAMPLE
n |
-----+------------------------------------------------
1 | 1
-----+------------------------------------------------
2 | 2
-----+------------------------------------------------
3 | 3
-----+------------------------------------------------
4 | 2
| 4 1,1
-----+------------------------------------------------
5 | 5
-----+------------------------------------------------
6 | 3 3
| 6 1,2 2,1
-----+------------------------------------------------
7 | 7
-----+------------------------------------------------
8 | 4 4 4
| 8 1,3 2,2 3,1
-----+------------------------------------------------
9 | 9
-----+------------------------------------------------
10 | 5 5 5 5
| 10 1,4 2,3 3,2 4,1
-----+------------------------------------------------
11 | 4
| 2,2
| 11 1,1,1
-----+------------------------------------------------
12 | 6 6 6 6 6
| 12 1,5 2,4 3,3 4,2 5,1
-----+------------------------------------------------
13 | 13
-----+------------------------------------------------
14 | 5 5
| 7 7 7 7 7 7 2,3 3,2
| 14 1,6 2,5 3,4 4,3 5,2 6,1 1,1,2 2,1,1
PROG
(Ruby)
def f(n)
ary = [1]
(n - 1).times{|i|
ary = [0] + ary + [0]
ary = (0..i + 1).map{|j| ary[j] + ary[j + 1] + 1}
}
ary
end
def A(n)
f_ary = (1..n / 2).map{|i| [i]}
cnt = 1
s = 1
while f_ary.size > 0
s_ary = f(s + 1)
b_ary = []
f_ary.each{|i|
(1..i[0] - 1).each{|j|
a = [j]
(0..s - 1).each{|k|
num = i[k] - a[k]
if num > 0
a << num
else
break
end
}
if a.size == s + 1
sum = (0..s).inject(0){|t, m| t + s_ary[m] * a[m]}
if sum < n
b_ary << a
elsif sum == n
cnt += 1
end
end
}
}
f_ary = b_ary
s += 1
end
cnt
end
def A337785(n)
(1..n).map{|i| A(i)}
end
p A337785(50)
CROSSREFS
Cf. A014430, A062684, A062896, A337765, A337766, see A337787 for version 2.
Sequence in context: A353960 A330756 A330747 * A290980 A007381 A366877
KEYWORD
nonn,look
AUTHOR
Seiichi Manyama, Sep 21 2020
STATUS
approved