Python factorial calculation

DaLongggggg 2021-04-08 09:24:28
python factorial calculation

Problem description

Enter a positive integer n, Output n! Value . among n!=123n.

Algorithm description

n! It could be very big , The range of integers that a computer can represent is limited , We need to use the method of high precision calculation . Use an array A To represent a large integer a,A[0] Express a A bit of ,A[1] Express a Top ten , By analogy . take a Multiply by an integer k Change to array A Every element of the matrix is multiplied by k, Please pay attention to the corresponding carry . First of all, will a Set to 1, Then take 2, ride 3, When you get to n when , taken n! Value .

Input format

The input contains a positive integer n,n<=1000.

Output format

Output n! The exact value of .

The sample input


Sample output

3628800 Particular attention n First of all, recursion can only solve 1 Factorials up to a few hundred

n = int(input())a = b =1while a <= n: b = b * a a += 1print(b)

Cycle fatigue


  1. Pandas-二进制操作
  2. python入门教程14-01 (python语法入门之python内存泄露)
  3. Web4 - get flag through Python
  4. python-web5
  5. Pandas binary operation
  6. python入门教程13-06 (python语法入门之视图、触发器、事务、存储过程、函数)
  7. python入门教程13-07 (python语法入门之ORM框架SQLAlchemy)
  8. python入门教程13-08 (python语法入门之python索引原理与慢查询优化)
  9. 定投指数到底能不能赚钱?Python 来告诉你答案
  10. Python入门学习之:10分钟1500访问量
  11. Getting started with Python 14-01
  12. 用 Python 画哆啦 A 梦
  13. Python 图表利器 pyecharts
  14. 用 Python 抓取公号文章保存成 HTML
  15. Introduction to Python 13-06 (view, trigger, transaction, stored procedure, function of introduction to Python syntax)
  16. Getting started with Python 13-07 (ORM framework Sqlalchemy for getting started with Python syntax)
  17. Introduction to Python 13-08
  18. Can fixed investment index make money? Python will tell you the answer
  19. Introduction to Python: 1500 visits in 10 minutes
  20. 用 Python 获取股市交易数据
  21. Drawing Doraemon in Python
  22. Python charts
  23. 用 Python 来了解一下《安家》
  24. 用 Python 抓取公号文章保存成 PDF
  25. 用 Python 生成炫酷二维码及解析
  26. Using Python to grab articles with public number and save them as HTML
  27. Getting stock market trading data with Python
  28. Learn about settle down in Python
  29. Using Python to grab articles with public number and save them as PDF
  30. Using Python to generate cool two dimensional code and analysis
  31. 20210225-1 Python错误与异常
  32. 20210225-1 Python errors and exceptions
  33. 使用Python拆分、合并PDF
  34. Using Python to split and merge pdf
  35. 真工程师:20块钱做了张「名片」,可以跑Linux和Python
  36. Implementation of LSB steganography based on MATLAB and python
  37. Real Engineer: 20 yuan to make a "business card", can run Linux and python
  38. python修改微信和支付宝步数
  39. Python changes WeChat and Alipay steps
  40. Python空间分析| 01 利用Python计算全局莫兰指数(Global Moran's I)
  41. Python spatial analysis | 01 using Python to calculate global Moran's index
  42. python入门教程13-05 (python语法入门之数据备份、pymysql模块)
  43. Introduction to Python 13-05 (data backup and pymysql module of introduction to Python syntax)
  44. pandas如何操作Excel?还不会的,看此一篇足矣
  45. How does panda operate excel? Not yet. This is enough
  46. 用python连接数据库模拟用户登录
  47. Using Python to connect database to simulate user login
  48. python入门教程13-04 (语法入门之记录相关操作)
  49. Introduction to Python 13-04
  50. python入门教程13-03 (python语法入门之表相关操作)
  51. Introduction to Python 13-03
  52. python的多线程的网络爬虫,待改进
  53. Python multithreaded web crawler, to be improved
  54. 常见加密算法的Python实现:
  55. Python implementation of common encryption algorithms:
  56. python刷题-核桃的数量
  57. Number of walnuts
  58. Python爬虫知乎文章,采集新闻60秒
  59. Python crawler knows articles and collects news for 60 seconds
  60. Python爬虫知乎文章,采集新闻60秒