DEV Community

Solve the sum of natural numbers using Ruby.

Yong Liang on March 22, 2019

Given a range of natural numbers, from 1 to 100 for example, find the sum of all the given numbers. Below, we will implement some solutions then so...
Collapse
 
jbristow profile image
Jon Bristow

Almost any regularly increasing range of numbers can be generalized like this!

Not all are super obvious, but if you see something like this in a coding challenge, figure out the equation (the above is sum(x)) and then try it out on wolframalpha.com