If N numbers add up to 2022, then the mean value of this set is 2022/N, and the first member of the sequence, "a", is 2022/N - (N-1)/2.
For the sequence elements to be integers, then either:
N is odd and 2022/N is an integer, or
N is even and 2022/N is an integer+1/2
A programs yields these solutions, showing N, the first integer of the sequence and the last:
N first last
1 2022 2022
3 673 675
4 504 507
12 163 174
337 -162 174
1011 -503 507
1348 -672 675
4044 -2021 2022
A function below I called sumNstartwitha(a,N) computes the sum of a sequence of consecutive integers starting with "a" and containing N elements. In each case this was equal to 2022.
----------- code -----------
listOf_a = []
listOf_N = []
for i in range(1,1000000):
if i%2 == 0 and (2022/i)%1 == .5:
listOf_a.append(int((2022/i) - (i-1)/2 ))
listOf_N.append(i)
print(i, int((2022/i) - (i-1)/2 ), int((2022/i) - (i-1)/2 ) + i - 1)
if i%2 == 1 and (2022/i)%1 == 0:
listOf_a.append(int((2022/i) - (i-1)/2 ))
listOf_N.append(i)
print(i, int((2022/i) - (i-1)/2 ), int((2022/i) - (i-1)/2 ) + i - 1)
Summing a, a+1, ... a+N-1
Let the 1st element of the sequence be "a". Then the series to be summed is a, a+1, ... , a+N-1.
And this sum is a*N + sum(0,1,...,N-1) = a*N + (N)(N-1)/2 = (N)(2a+N-1)/2 = (N^2 + 2aN - N)/2
----------- function -----------
def sumNstartwitha(a,N):
""" returns sum of N consecutive integers starting from a """
return int(N*(2*a + N - 1)/2)