7 kyu
Beginner Series #3 Sum of Numbers
14,833 of 218,046Vortus
Description:
Given two integers a
and b
, which can be positive or negative, find the sum of all the integers between and including them and return it. If the two numbers are equal return a
or b
.
Note: a
and b
are not ordered!
Examples (a, b) --> output (explanation)
(1, 0) --> 1 (1 + 0 = 1)
(1, 2) --> 3 (1 + 2 = 3)
(0, 1) --> 1 (0 + 1 = 1)
(1, 1) --> 1 (1 since both are same)
(-1, 0) --> -1 (-1 + 0 = -1)
(-1, 2) --> 2 (-1 + 0 + 1 + 2 = 2)
Your function should only return a number, not the explanation about how you get that number.
Fundamentals
Algorithms
Similar Kata:
Stats:
Created | Sep 11, 2015 |
Published | Sep 11, 2015 |
Warriors Trained | 360179 |
Total Skips | 36873 |
Total Code Submissions | 891525 |
Total Times Completed | 218046 |
C# Completions | 14833 |
Java Completions | 26124 |
Python Completions | 76444 |
JavaScript Completions | 74038 |
CoffeeScript Completions | 169 |
Ruby Completions | 6744 |
TypeScript Completions | 3632 |
C Completions | 5958 |
R Completions | 479 |
NASM Completions | 78 |
F# Completions | 160 |
Haskell Completions | 1154 |
Julia Completions | 142 |
Prolog Completions | 62 |
Scala Completions | 543 |
C++ Completions | 7956 |
Pascal Completions | 123 |
Crystal Completions | 27 |
Shell Completions | 314 |
Clojure Completions | 179 |
COBOL Completions | 23 |
Rust Completions | 1415 |
Go Completions | 1820 |
Lua Completions | 55 |
PHP Completions | 162 |
Total Stars | 2486 |
% of votes with a positive feedback rating | 88% of 16776 |
Total "Very Satisfied" Votes | 13165 |
Total "Somewhat Satisfied" Votes | 3271 |
Total "Not Satisfied" Votes | 340 |