python isqrt()方法

    科技2022-08-09  114

    原文 Python | math.isqrt() method Last Updated: 14-01-2020 Math module in Python contains a number of mathematical operations, which can be performed with ease using the module. math.isqrt() method in Python is used to get the integer square root of the given non-negative integer value n. This method returns the floor value of the exact square root of n or equivalently the greatest integer a such that a2 <= n.

    Note: This method is new in Python version 3.8.

    Syntax: math.isqrt(n) Parameter: n: A non-negative integer Returns: an integer value which represents the floor of exact square root of the given non-negative integer n. # Python Program to explain # math.isqrt() method import math n = 10 # Get the floor value of # exact square root of n sqrt = math.isqrt(n) print(n) n = 100 # Get the floor value of # exact square root of n sqrt = math.isqrt(n) print(n)

    output:

    3 10
    Processed: 0.013, SQL: 8