calculates pi, is quicker in turbo mode. k/2 is how many steps were performed. val is 1/4 of pi because this algorithm only gives you 1/4 of it.
just for fun, i made it in ~10 mins.