fork download
  1. table = [{res: -155721, kd: 1, tds: -155721, tdsn: -155721},
  2. {res: 148893, kd: nil, tds: nil, tdsn: nil},
  3. {res: 148893, kd: nil, tds: nil, tdsn: nil},
  4. {res: 238339, kd: nil, tds: nil, tdsn: nil},
  5. {res: 238339, kd: nil, tds: nil, tdsn: nil},
  6. ]
  7. e = 1.3
  8. 4.times do |i|
  9. table[i+1][:kd] = (1/(1+e)**(i+1)).round(4)
  10. table[i+1][:tds] = (table[i+1][:kd]*table[i+1][:res]).round
  11. table[i+1][:tdsn] = (table[i][:tdsn]+table[i+1][:tds]).round
  12. end
  13. table.each do |i|
  14. i.each {|k,v| print v.to_s+" "}
  15. print "\n"
  16. end
Success #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
-155721      1      -155721      -155721      
148893      0.4348      64739      -90982      
148893      0.189      28141      -62841      
238339      0.0822      19591      -43250      
238339      0.0357      8509      -34741