The sum of a sequence of N
consecutive integers is 2022, where N is greater than 2.
Determine all possible values of N, and the valid sequence for each value of N.
clearvars
for N=3:800000
b=2022/N - (N-1)/2;
if b==round(b)
fprintf('%7d %d - %d\n',N,b,b+N-1);
end
end
finds
3 673 - 675
4 504 - 507
12 163 - 174
337 -162 - 174
1011 -503 - 507
1348 -672 - 675
4044 -2021 - 2022
where each is N followed by the range.
|
Posted by Charlie
on 2022-05-25 11:41:48 |