square root function in r (iterative)