How many distinct trapezoidal
decompositions (sum of consecutive
positive integers) does n have?
For example, 15 = 7+8 = 4+5+6 =
1+2+3+4+5 has three.
Wolfram Alpha was used to find the solution to
(f+l)*(l-f+1)/2 = n for l (that's a lower case L)
so we could find, if it exists (the formula produces an integer), the last term in the sequence (l) given the first (f). The formula was used in the program:
clearvars
sol=[];
for n=1:25
ct=0;
for f=1:n/2
l = (sqrt(4*f^2 - 4*f + 8*n + 1) - 1)/2;
if abs(l-round(l))<.0000001
% disp([n f l])
ct=ct+1;
end
end
disp([n ct])
sol(end+1)=ct;
end
fprintf('%d,',sol)
fprintf('\n')
The findings:
n ways
1 0
2 0
3 1
4 0
5 1
6 1
7 1
8 0
9 2
10 1
11 1
12 1
13 1
14 1
15 3
16 0
17 1
18 2
19 1
20 1
21 3
22 1
23 1
24 1
25 2
0,0,1,0,1,1,1,0,2,1,1,1,1,1,3,0,1,2,1,1,3,1,1,1,2,
The last line was for entry into the OEIS, which found A069283, a(n) = -1 + number of odd divisors of n, but which also notes that it is the
Number of nontrivial ways to write n as sum of at least 2 consecutive integers. That is, we are not counting the trivial solution n=n.
And it does turn out that
for n=1:25
d=divisors(n);
d=d(mod(d,2)==1);
disp([n length(d)-1])
end
produces the same list, though it's slower.
|
Posted by Charlie
on 2025-02-03 08:34:28 |