Number of ways to express a number as summation of consecutive numbers

Question.All the positive numbers can be expressed as a sum of one, two or more consecutive positive integers. For example 9 can be expressed in three such ways, 2+3+4, 4+5 or 9. Given an integer ,you will have to determine in how many ways that number can be expressed as summation of consecutive numbers.

Solution:
2+3+4=(1+2+3+4)-(1)
=(1+2+3+4+5)-(1+2+3)
=(1+2+3+4+5+6+7+8+9)-(1+2+3+4+5+6+7+8)

This shows that the no of solutions to this problem is the no of tuples (n,m) such that
given number K can be expressed as K=(1+2+..........+n)-(1+2+3+...........+m)
and n > m

i.e K=n*(n+1)/2 -m*(m+1)/2
=(n-m)(n+m+1)/2
2*k=(n-m)*(n+m+1)
If we put the factor n-m=p and (n+m+1)=q,we get S=2*k=p*q
As p+q=2*n+1 is odd and S is even either n-m is odd otherwise n+m+1 is odd.
This leaves out with finding out the no of odd divisors of S,which can be easily done using prime factorization.
if S=(2^p)*(3^q)*(5^r)*(7^s)......

then the solution is (q+1)*(r+1)*(s+1)*.. i.e the no of odd divisors of S.


click here for more questions

No comments:

Post a Comment