我试图找到并打印满足ca> = cb的n的最小值:
ap = 80000
bp = 200000
at = 1.03
bt = 1.015
n = 1
ca = ap*at*n
cb = bp*bt*n
while cb > ca:
n = n + 1
print(n)
代码只是运行并无限期地打印n + 1。解决这个问题的正确方法是什么?
答案 0 :(得分:0)
ap = 80000
bp = 200000
at = 1.03
bt = 1.015
n = 1
ca = ap*at*n
cb = bp*bt*n
while cb > ca:
n += 1
ca = ap*at*n
cb = bp*bt*n
虽然这不会收敛。