Método Python math.isqrt()
Ejemplo
Redondea un número de raíz cuadrada hacia abajo al entero más cercano:
# Import math Library
import math
# Print the square
root of different numbers
print (math.sqrt(10))
print (math.sqrt (12))
print (math.sqrt (68))
print (math.sqrt (100))
# Round square root
downward to the nearest integer
print (math.isqrt(10))
print
(math.isqrt (12))
print (math.isqrt (68))
print (math.isqrt (100))
Definición y uso
El math.isqrt()
método redondea un número de raíz cuadrada hacia abajo al entero más cercano.
Nota: El número debe ser mayor o igual a 0.
Sintaxis
math.isqrt(x)
Valores paramétricos
Parameter | Description |
---|---|
x | Required. The number to round the square root of. If x is negative, it returns a ValueError. If x is not a number, it returns a TypeError |
Detalles técnicos
Valor devuelto: | Un int valor, que representa la raíz cuadrada de un número, sin decimales |
---|---|
Versión de Python: | 3.8 |