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

Stats:

CreatedSep 11, 2015
PublishedSep 11, 2015
Warriors Trained360179
Total Skips36873
Total Code Submissions891525
Total Times Completed218046
C# Completions14833
Java Completions26124
Python Completions76444
JavaScript Completions74038
CoffeeScript Completions169
Ruby Completions6744
TypeScript Completions3632
C Completions5958
R Completions479
NASM Completions78
F# Completions160
Haskell Completions1154
Julia Completions142
Prolog Completions62
Scala Completions543
C++ Completions7956
Pascal Completions123
Crystal Completions27
Shell Completions314
Clojure Completions179
COBOL Completions23
Rust Completions1415
Go Completions1820
Lua Completions55
PHP Completions162
Total Stars2486
% of votes with a positive feedback rating88% of 16776
Total "Very Satisfied" Votes13165
Total "Somewhat Satisfied" Votes3271
Total "Not Satisfied" Votes340
Ad
Contributors
  • Vortus Avatar
  • jhoffner Avatar
  • Unnamed Avatar
  • CrazyMerlyn Avatar
  • DivyanshBatham Avatar
  • anter69 Avatar
  • DealPete Avatar
  • SleepingCode Avatar
  • Chrono79 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • WKalmar Avatar
  • B1ts Avatar
  • ThorstenLudwig Avatar
  • Blind4Basics Avatar
  • acjoker Avatar
  • Souzooka Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • Smolkis Avatar
  • wrobs Avatar
  • bassopenguin Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • ___i Avatar
  • __Anonymous__ Avatar
  • Ssstlis Avatar
  • uniapi Avatar
  • stellartux Avatar
  • guriyeller Avatar
  • username0 Avatar
  • user8436785 Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Rocketboomer Avatar
  • sid114 Avatar
  • KayleighWasTaken Avatar
  • metatable Avatar
Ad