2

我需要得到平方根的上限,例如10**10001(10^10001)。如果我做:

from math import sqrt
print(int(sqrt(10**10001))+1)

我看了一下,它给了我一个OverflowError. 更准确地说,一个

Traceback (most recent call last)
  File <stdin>, line 1, in <module>
OverflowError: int too large to convert to float.

我需要一个整数来回答。来自OverflowError函数math.sqrt(x)。如果有人可以提供帮助,将不胜感激。

4

1 回答 1

-2

数学模块具有 ceil 和 floor 功能

尝试打印(math.ceil(math.sqrt(NUMBER)))

于 2020-11-06T14:00:57.080 回答