for a given positive integer n determine if it can be represented as a sum of two fibonacci numbers 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.

const getSum = (a, b) => a === b ? a : getSum(a + (a < b)?1:-1, b);

Tags:

Misc Example