python求多个数的阶乘并生成散点图?

如何用python求多个数的阶乘并生成散点图

第1个回答  2019-11-12


import matplotlib.pyplot as plt

n = 5 #自定义最大阶乘值

r = []

for i in range(1, n+1):
temp = 1
for j in range(1, i + 1):
temp = temp * j
r.append(temp)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(list(range(1, n+1)), r)
plt.show()

第2个回答  2019-11-12
生活,还是需要各种各样的提升。
相似回答