用 while 语句求 1!+2! +3! +......+20!
时间: 2023-11-17 22:03:35 浏览: 98
Java求1+2!+3!+...+20!的和的代码
5星 · 资源好评率100%
```pyth\# 初始化变量\ = 1\sum = \# 循环计算阶乘和\whi <= 20\ # 计算当前数的阶乘\ i = 1\ factori = 1\ whi i <= \ factori *= i\ i += 1\ # 将阶乘加入总和中\ sum += factori\ += 1\# 输出结果\pri(\1!+2!+3!+...+20!=\", sum)\```\
阅读全文