Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 498 Bytes

multiply_the_number.md

File metadata and controls

20 lines (17 loc) · 498 Bytes

Description

Jack really likes his number five: the trick here is that you have to multiply each number by 5 raised to the number of digits of each numbers, so, for example:

multiply(3) == 15 # 3 * 5¹
multiply(10) == 250 # 10 * 5²
multiply(200) == 25000 # 200 * 5³
multiply(0) == 0 # 0 * 5¹
multiply(-3) == -15 # -3 * 5¹

My Solution

def multiply(n)
  n * 5 ** n.abs.digits.size
end