require'mathn' def g(o,l=[]) p l if l.inject(:+)==o#db (l.last||1..o).each{|d|d.prime?and g(o,l+[d])if l.count<5} end g(27)
Standard input is empty
[2, 2, 2, 2, 19] [2, 2, 3, 3, 17] [2, 2, 3, 7, 13] [2, 2, 5, 5, 13] [2, 2, 5, 7, 11] [2, 2, 23] [2, 3, 3, 19] [2, 3, 5, 17] [2, 3, 11, 11] [2, 5, 7, 13] [2, 7, 7, 11] [3, 3, 3, 5, 13] [3, 3, 3, 7, 11] [3, 3, 5, 5, 11] [3, 3, 7, 7, 7] [3, 5, 5, 7, 7] [3, 5, 19] [3, 7, 17] [3, 11, 13] [5, 5, 5, 5, 7] [5, 5, 17] [5, 11, 11] [7, 7, 13]