[자바스크립트로 구현한 알고리즘] Beginner Series #3 Sum of Numbers

남양주개발자

·

2016. 9. 17. 16:21

728x90
반응형


Given two integers, which can be positive and negative, find the sum of all the numbers between including them too and return it. If both numbers are equal return a or b. Note! a and b are not ordered! 


Example: 

GetSum(1, 0) == 1 // 1 + 0 = 1 

GetSum(1, 2) == 3 // 1 + 2 = 3 

GetSum(0, 1) == 1 // 0 + 1 = 1 

GetSum(1, 1) == 1 // 1 Since both are same 

GetSum(-1, 0) == -1 // -1 + 0 = -1 

GetSum(-1, 2) == 2 // -1 + 0 + 1 + 2 = 2 



728x90
반응형
그리드형

💖 저자에게 암호화폐로 후원하기 💖

아이콘을 클릭하면 지갑 주소가자동으로 복사됩니다