GET_NUMBER = gets.to_i output = 0 remaining_match = GET_NUMBER unless (GET_NUMBER % 2).zero? output = 7 remaining_match -= 3 end until remaining_match == 0 output = output * 10 + 1 remaining_match -= 2 end puts output