-
翻阅古今
produkt = 1counter = 2while produkt < 1000: print(produkt, end=" ") produkt = produkt * counter counter += 1print(produkt)1 2 6 24 120 720 5040
-
收到一只叮咚
只是为了好玩。>>> next(filter(1000 .__lt__, itertools.accumulate(itertools.count(1), operator.mul)))
5040
-
慕雪6442864
我想你想要:number = 1produkt = numberwhile produkt<=1000: print(produkt) number += 1 produkt = produkt * number结果:12624120720
-
浮云间
您需要 2 个变量,一个用于存储,total另一个用于存储index(1, 2, 3, ...)index = 1total = 1while index < 1000: total *= index # same as: total = total * index index += 1 # same as: index = index +1 # print(f'{index - 1} => {total}') uncomment if you want to follow the valuesprint(f"Stop at total {total}, index was {index}")你会得到以下内容1 => 12 => 23 => 64 => 245 => 1206 => 7207 => 50408 => 403209 => 36288010 => 3628800...Stop at total 402...000, index was 1000
-
温温酱
您可以按以下方式修改代码:变量produkt取值 1,2,3,...,它们的乘积存储在produkt_end.produkt = 1produkt_end = 1while True: print(produkt_end) produkt_end = produkt_end*produkt produkt = produkt+1 if produkt_end > 1000: break它将显示produkt_end:112624120720