All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers > Sequences
Consecutive Conclusion II (Posted on 2022-05-25) Difficulty: 3 of 5
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.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 1 of 3
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)


  Posted by Larry on 2022-05-25 10:45:41
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information