Coding Exercises

Find All Potential Products in Ruby

This guide examines how to properly find the full set of potential products in a Ruby collection.

Summary

Build a method that returns all of the divisible items of two integers.

Exercise File

Code File

Exercise Description

Implement a method that returns all of the potential products of two integers in Ruby up through a certain range.

Sample Input

1..120000 # range
200 # number 1
73 # number 2

Expected Output

[14600, 29200, 43800, 58400, 73000, 87600, 102200, 116800]

Real World Usage

This exercise will test your knowledge of how to work with the modulus operator and ranges. Additionally, you’ll learn how to return a full collection of selected items.

Solution

Can be found on the solutions branch on github.

Jordan Hudgens
the authorJordan Hudgens

4 Comments

Leave a Reply