Just Another Sum Problem But... 😰😱

Published by Mubashir Hassan in

Ok, the challenge is kind of easy, right?

The problem is not adding. The problem is that the numbers are not in order. Create a function that organizes the numbers and adds the numbers in the range between X and Y.

Here is an example:

X = -10 | Y=1

So this will be the range of numbers:

-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1

This will be your result:

-54

Remember, X and Y are disorganized, so to get to the result you know what you have to do.

Examples

justAnotherSumProblem(-10, 1) âžž -54

justAnotherSumProblem(-20, 5) âžž -195

justAnotherSumProblem(90, 45) âžž 3105

Notes

Check out the Resources tab if you need some help :)

Watch a quick demo on how Edabit works.