https://leetcode.com/problems/sqrtx Easy

Решение

class Solution {
    fun mySqrt(x: Int): Int {
        if (x == 0) return 0
        var r = x.toLong()
        val n = x.toLong()
        while (r * r > n) r = (r + n / r) ushr 1
        return r.toInt()
    }
}