Loading Skulpt Python Interpreter...

Loading from jsDelivr CDN. This should be fast and reliable.

Simple Adding

Easy
Math
Acceptance: 87.3%

Have the function SimpleAdding(num) add up all the numbers from 1 to num. For example: if the input is 4 then your program should return 10 because 1 + 2 + 3 + 4 = 10. For the test cases, the parameter num will be any number from 1 to 1000.

Examples

Example 1:

Input:12
Output:78
Explanation:1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 = 78

Example 2:

Input:140
Output:9870
Explanation:Sum of all numbers from 1 to 140 equals 9870

Example 3:

Input:4
Output:10
Explanation:1 + 2 + 3 + 4 = 10

Constraints

  • 1 <= num <= 1000
  • num will always be a positive integer
  • Return the sum as an integer

Code Editor

python