#!ruby -n g=d=1e3 k=1 puts"#{g=0|0.5+g-k*d/=2} "<$_.to_i while 0!=k puts