[자바스크립트로 구현한 알고리즘] 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
반응형
그리드형
'Computer science > 알고리즘' 카테고리의 다른 글
[자바스크립트로 구현한 알고리즘] Stringy Strings (0) | 2016.09.17 |
---|---|
[자바스크립트로 구현한 알고리즘] Disemvowel Trolls (0) | 2016.09.17 |
[자바스크립트로 구현한 알고리즘] Return Negative (0) | 2016.09.17 |
[자바스크립트로 구현한 알고리즘] Convert number to reversed array of digits (0) | 2016.09.14 |
[자바스크립트로 구현한 알고리즘] Sum of positive (0) | 2016.09.14 |