i = 100 arr = Array[] while i >= 7 arr << i%7 i/=7 end arr << i res = arr.join.reverse! puts res