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 = 0.8
  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.5556      82725      -72996      
148893      0.3086      45948      -27048      
238339      0.1715      40875      13827      
238339      0.0953      22714      36541