6 Given a positive integer, tell whether it is equal to the sum of four consecutive integers. code example
Example 1: Given two integers a and b, which can be positive or negative, find the sum of all the integers between including them too and return it. If the two numbers are equal return a or b.
getSum(1,3)
1 + getSum(2,3)
1 + ( 2 + getSum(3,3))
1 + ( 2 + (3))
Example 2: Given two integers a and b, which can be positive or negative, find the sum of all the integers between including them too and return it. If the two numbers are equal return a or b.
return 2 + getSum(2 + 1, 3)
Example 3: Given two integers a and b, which can be positive or negative, find the sum of all the integers between including them too and return it. If the two numbers are equal return a or b.
const getSum = (a, b) => 1/2 * Math.abs((a ** 2 + a - b ** 2 - b));