7 kyu
Beginner Series #3 Sum of Numbers
14,883 of 219,161Vortus
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 | 361738 |
Total Skips | 37004 |
Total Code Submissions | 895074 |
Total Times Completed | 219161 |
C# Completions | 14883 |
Java Completions | 26239 |
Python Completions | 76895 |
JavaScript Completions | 74362 |
CoffeeScript Completions | 169 |
Ruby Completions | 6752 |
TypeScript Completions | 3663 |
C Completions | 5987 |
R Completions | 480 |
NASM Completions | 78 |
F# Completions | 160 |
Haskell Completions | 1158 |
Julia Completions | 143 |
Prolog Completions | 62 |
Scala Completions | 545 |
C++ Completions | 8018 |
Pascal Completions | 124 |
Crystal Completions | 28 |
Shell Completions | 320 |
Clojure Completions | 180 |
COBOL Completions | 23 |
Rust Completions | 1425 |
Go Completions | 1849 |
Lua Completions | 55 |
PHP Completions | 178 |
Total Stars | 2491 |
% of votes with a positive feedback rating | 88% of 16815 |
Total "Very Satisfied" Votes | 13197 |
Total "Somewhat Satisfied" Votes | 3276 |
Total "Not Satisfied" Votes | 342 |