怎么解决[Previous line repeated 997 more times] MemoryError: Stack overflow
import numpy as np
import sys
sys.setrecursionlimit(1000000)
def get_value(n):
if n==1:
return n
else:
return n * get_value(n-1)
def gen_last_value(n,m):
first = get_value(n)
second = get_value(m)
third = get_value((n-m))
return first/(second * third)
if __name__ == "__main__":
VOLi = 10000
pt = 0.5
for i in np.arange(0, VOLi + 1):
rest = gen_last_value(VOLi,i)
pr=rest*(pt**i)*(1-pt)**(VOLi-i)
print(rest)
`
来源:CSDN
作者:风云0707
链接:https://blog.csdn.net/weixin_43284071/article/details/103243844