fork download
  1. require'mathn'
  2. def g(o,l=[])
  3. p l if l.inject(:+)==o#db
  4. (l.last||1..o).each{|d|d.prime?and g(o,l+[d])if l.count<5}
  5. end
  6.  
  7. g(27)
  8.  
Success #stdin #stdout 0.07s 5548KB
stdin
Standard input is empty
stdout
[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]