• Home
  • Public Speaking
  • Travel

Consequtive Sums

Problem:
Given a number N, find the number of ways to represent this number as a sum of 2 or more consecutive natural numbers.

Approach:
N = a + (a+1) + (a+2) + .. + (a+L)
=> N = (L+1)*a + (L*(L+1))/2

Java Code: