当前位置:网站首页>Writing of factorial
Writing of factorial
2022-07-28 16:03:00 【Siege lion Yimu】
CreatDate:2021.10.20
problem :F(n)=1!+2!+3!+...+n!, Programming requirements F(50),F(100),F(1000) Value (n! Represents factorial operation )
The first way to write it :
n = int(input(' Input n Value : '))
res = 0
i = 1
j = 1
while n >= i:
j *= i
res += j
i += 1
print(res)Input n Value : 2 3
The second way :
math The library has ready-made functions :factorial(n)
def func(n):
from math import factorial as fact
res = 0
for i in range(1,n+1):
res += fact(i)
return res
func(50)31035053229546199656252032972759319953190362094566672920420940313
Today, through learning in the Group , I feel more like I have found the right direction , Keep learning , Also adhere to the daily summary .
边栏推荐
- 便携式钻孔测斜仪数据采集仪测量原理与测斜探头的连接及使用方法
- js 队列
- 不懂就问,快速成为容器服务进阶玩家!
- Software architecture and design (I) -- key principles
- A failed cracking experience
- 远距离串口服务器( 适配器)UART/I2C/1-Wire/SPI PS304常见问题及注意事项
- Camera continuous shooting automatic test shell script
- How to effectively conduct the review meeting (Part 1)?
- PyQt5快速开发与实战 5.2 容器:装载更多的控件
- Installation points and precautions of split angle probe
猜你喜欢

0-75mv/0-100mv to rs485/232 communication interface Modbus RTU acquisition module ibf8

Ask if you don't understand, and quickly become an advanced player of container service!

NTC,PT100热电阻转4-20mA温度信号转换器

JS queue

js 优先级队列

MLX90640 红外热成像仪测温传感器模块开发笔记(八)

Software architecture and design (IV) -- data flow architecture

What is the concept of game testing? What are the test methods and processes?

JS stack

占空比开关量输出高速脉冲计数器RTUModbus模块IBF63
随机推荐
R语言使用GGally包的ggpairs函数可视化分组多变量的两两关系图、设置alpha参数改变图像透明度、对角线上连续变量密度图、离散变量条形图、两两关系图中包含散点图、直方图、箱图以及相关性数值
Data real-time feedback technology
Advantages of optical rain gauge over tipping bucket rain gauge
记:数值向上取整十,整百,整千,整万
NTC, PT100 thermal resistance to 4-20mA temperature signal converter
Pyqt5 rapid development and practice 5.1 tables and trees
Docker implements redis cluster mode hash slot partition for 100 million level data storage
Solve the problem that the right-click menu "edit with idle" of the 『 py 』 file is invalid or missing
多功能混合信号AI采集/开关量DI/DO采集转RS485/232/MODBUS模块
Shell编程规范与变量
[channel attention mechanism] senet
2路DI高速脉冲计数器1路编码器转Modbus TCP有线无线模块IBF161
Software architecture and design (IX) -- component based architecture
Multifunctional mixed signal AI acquisition / switching value di/do acquisition to rs485/232/modbus module
2021 Yahong pen test question 2
使用systemd管理服务
激光测距仪非接触式地表裂缝监测仪
振弦采集模块测量振弦传感器的流程步骤?
一次失败的破解经历
虚拟机之NAT模式下设置静态IP