当前位置:   article > 正文

python练习题002:数字的阶乘_python计算6的阶乘

python计算6的阶乘
# 6的阶乘:6*5*4*3*2*1
# 3的阶乘:3*2*1
  1. i = 5
  2. result = 6
  3. while i >= 1:
  4. result = result * i
  5. print(result)
  6. i = i - 1
  7. def get_jiecheng(number):
  8. result = 1
  9. while number > 0:
  10. result *= number
  11. number -= 1
  12. return result
  13. print("jiecheng 6 = " ,get_jiecheng(6))
  14. print("jiecheng 3 = " ,get_jiecheng(3))
  15. print("jiecheng 100 = " ,get_jiecheng(100))
  16. def get_jiecheng(number):
  17. result = 1
  18. while number>0:
  19. result *= number
  20. number -= 1
  21. return result
  22. print (get_jiecheng(6))

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/212713
推荐阅读
相关标签
  

闽ICP备14008679号