Test cases:
Test cases | Expected | Result |
---|---|---|
sum(10,12) | 22 | OK |
sum(1,2) | 3 | OK |
sum(2147483647,1) | 2147483648 | OK |
Java solution:
public class Sum {
public static void main(String[] args) {
Sum.sum(10, 12);
Sum.sum(1, 2);
Sum.sum(2147483647, 1);
}
public static long sum(int a,int b){
return (long)a + b;
}
}
Javascript solution:
const sum = (a, b) => {
return a + b;
}
console.log(sum(10, 12)); //22
console.log(sum(1, 2)); //3
console.log(sum(2147483647,1)); //2147483648