Finding Divisors

Realize the importance of mathematics in programming and solve a mathematical problem using Ruby.

Importance of mathematics in programming

Computers were originally created to do mathematical computations. Math is an essential part of software design. It may not sound fun, but programming can add a fun factor to math.

  • Programming allows us to understand math better.

  • We can utilize our math skills to solve problems.

Problem

Write a program to list all the divisors of a number.

  • Assume that the number is already saved in an input variable made available in the code editor.

  • The divisors list must be stored in an array of integers named array, which is also available in the code editor.

Get hands-on with 1400+ tech skills courses.