Using Ruby’s Detect Method to Find Divisible Numbers

1
1199

In this guide you’ll learn how to find divisible numbers by leveraging Ruby’s detect method.

Summary

Build a method that finds the first divisible number of two integers.

Exercise File

Code File

Exercise Description

Given two integers, build a method that returns the first number that is divisible by both numbers.

Sample Input

Given the numbers:

12, 16

Expected Output

48

Real World Usage

Finding divisible numbers is a common coding interview question. Additionally, it’s an important concept when working with mathematical equations.

Solution

Can be found on the solutions branch on github.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here