Ruby Coding Interview Question: Build a Dynamic Sum Method

This coding exercise walks through how to build a method that takes a single integer as an argument and builds a sum of all of the integers counting up to the argument value.

Summary

Build a program that sums all of the integers up to, and including any value passed in as an argument.

Exercise File

Code File

Exercise Description

The program should be able to take in a single argument of an integer, and output the sum of all of the integers up to the argument’s value.

Sample Input

10

Sample Output

55

Real World Usage

This is a common Ruby coding interview question. Additionally, being able to create dynamic ranges and perform calculations on the collection is important in a number of applications.

Solution

Can be found on the solutions branch on github.

Jordan Hudgens

view all post
Leave a comment

Please be polite. We appreciate that.

By Daniele Zedda • 18 February

← PREV POST

By Daniele Zedda • 18 February

NEXT POST → 34
Share on