Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 413 Bytes

grasshopper_summation.md

File metadata and controls

19 lines (16 loc) · 413 Bytes

Description

Summation

Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0.

For example (Input -> Output):

2 -> 3 (1 + 2)
8 -> 36 (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8)

My Solution

def summation(num)
  (1..num).sum
end