【发布时间】:2010-05-07 08:21:14
【问题描述】:
如何在 range() 函数中包含上限?我不能加 1,因为我的 for 循环看起来像:
for x in range(1,math.floor(math.sqrt(x))):
y = math.sqrt(n - x * x)
但据我了解,它实际上是1 < x < M 我需要1 < x <= M 添加1 将完全改变结果。
我正在尝试将我的旧程序从 C# 重写为 Python。这就是它在 C# 中的样子:
for (int x = 1; x <= Math.Floor(Math.Sqrt(n)); x++)
double y = Math.Sqrt(n - x * x);
-
两者都不。
range给你1 <= x < M。 -
math.ceil呢?
标签: python