Given a positive integer n, determine whether you can make n by summing up some non-negative multiple of 3 and some non-negative multiple of 7. 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.

function GetSum(a, b) {
    let lower, higher;
    let result = 0;
    //return either of it if they are equal
    if(a == b) {
        return a;
    } else {
        if(a > b) {
            higher = a;
            lower = b;
        } else {
            higher = b;
            lower = a;
        }
        for(i = lower; i <= higher; i++) {
            result += i;
        }
    }
    return result;
}
console.log(GetSum(3, 9))

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.

getSum(1,3)
 1 + getSum(2,3)
 1 + ( 2 + getSum(3,3))
 1 + ( 2 + (3))

Tags:

Misc Example