def isqrt(n):
    """
    Greatest integer less than or equal to the square root of n.
    Shamelessly stolen from https://codegolf.stackexchange.com/a/9088.
    Input: n -- a whole number
    Output: An integer
    Examples:
    >>> list(map(isqrt, range(25)))
    [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4]
    """
    if n < 0:
        return int(n)
    c = n * 4 // 3
    d = c.bit_length()
    a = d >> 1
    if d & 1:
        x = 1 << a
        y = x + (n >> a) >> 1
    else:
        x = 3 << a >> 2
        y = x + (c >> a) >> 1
    if x != y:
        x, y = y, y + n // y >> 1
        while y < x:
            x, y = y, y + n // y >> 1
    return x
