我不知道如何让我的代码重复,直到为 s 输入负值。
s=1000
S= 0
N= 0
while (S <= s):
N+=1
S+=N**3
print(f"The smallest sum of n**3 greater than {s} is {S}, where N = {N}")```
Python While 循环
Python input() 函数
while True:
s= int(input())
if s < 0: break
S= 0
N= 0
while (S <= s):
N+=1
S+=N**3
print(f"The smallest sum of n**3 greater than {s} is {S}, where N = {N}")