Sum Up To
MATH

Problem

Given an integer n, return the sum of all integers from 1 up to n inclusive.

Examples

sumUpTo(4); // returns 10, because 1 + 2 + 3 + 4 = 10 sumUpTo(1); // returns 1, because 1 = 1 sumUpTo(10); // returns 55, because 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55 sumUpTo(0); // returns 0, because there are no numbers to sum up
Loading...