changed intsqrt algorithm to binary search