n = gets.to_i (1...n).each do |a| (a...n).each do |b| c = n - a - b break if b > c puts "#{a} #{b} #{c}" end end