Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 417 Bytes

File metadata and controls

19 lines (16 loc) · 417 Bytes

Description

Task Overview

Given a non-negative integer n, write a function to_binary/ToBinary which returns that number in a binary format.

Example:

to_binary(1)  # should return 1
to_binary(5)  # should return 101
to_binary(11) # should return 1011

My Solution

def to_binary(n)
  n.to_s(2).to_i
end