Consecutive Sum Check

Published by Mubashir Hassan in

Create a function that takes a number n as an argument and checks whether the given number can be expressed as a sum of two or more consecutive positive numbers.

Examples

consecutiveSum(9) ➞ true
# 9 can be expressed as a sum of (2 + 3 + 4) or (4 + 5).

consecutiveSum(10) ➞ true
# 10 can be expressed as a sum of 1 + 2 + 3 + 4.

consecutiveSum(64) ➞ false

Notes

N/A

Watch a quick demo on how Edabit works.