re: Daily Challenge #24 - Shortest Step VIEW POST

FULL DISCUSSION
 

Ruby:

number = 12

def step(n, step)
  return step if n == 1

  n = n % 2 == 0 ? n / 2 : n -= 1
  step(n, step + 1)
end

puts step(number, 0)

:)

code of conduct - report abuse