fork download
  1. n = gets.to_i
  2. found = false
  3.  
  4. (10..99).each do |num|
  5. tens = num / 10
  6. ones = num % 10
  7. if tens + ones == n
  8. puts "#{num} = #{tens} + #{ones} = #{n}"
  9. found = true
  10. end
  11. end
  12.  
  13. puts "NO" unless found
  14.  
Success #stdin #stdout 0.01s 8072KB
stdin
8

stdout
17 = 1 + 7 = 8
26 = 2 + 6 = 8
35 = 3 + 5 = 8
44 = 4 + 4 = 8
53 = 5 + 3 = 8
62 = 6 + 2 = 8
71 = 7 + 1 = 8
80 = 8 + 0 = 8