<>; for(<>){ ($a,$b,$c,$k)=glob; for(1..$k){ ($a,$b,$c)=($b+$c>>1,$c+$a>>1,$a+$b>>1); last if$a==$b&&$a==$c; } print$a+$b+$c,$/; }