Python Tutorial Python Advanced Python References Python Libraries

Python math - isqrt() Function



The Python math.isqrt() function returns the integer square root of the non-negative integer n. This is the floor of the exact square root of n, or equivalently the greatest integer a such that a2 ≤ n.

Note: This function is added in version 3.8.

Syntax

#New in version 3.8
math.isqrt(n)

Parameters

n Required. Specify a number.

Return Value

Returns the integer square root of the specified number.

Example:

In the example below, isqrt() function is used to calculate the integer square root of the given non-negative number.

import math

print(math.isqrt(25))
print(math.isqrt(30))
print(math.isqrt(55))

The output of the above code will be:

5
5
7

❮ Python Math Module