[Python] python处理大数字代码 →→→→→进入此内容的聊天室

来自 , 2019-07-16, 写在 Python, 查看 108 次.
URL http://www.code666.cn/view/1977ab8c
  1. # check the numeric range of Python with huge factorials
  2. # factorial(69) still checks out accurately! Has 98 digits in it!
  3. # 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
  4. # tested with Python24      vegaseat    01aug2005
  5.  
  6. def getFactorial(n):
  7.     """returns the factorial of n"""
  8.     if n == 0:
  9.         return 1
  10.     else:
  11.         k = n * getFactorial(n-1)
  12.         return k
  13.  
  14. for k in range(1, 70):
  15.     print "factorial of", k,"=", getFactorial(k)
  16. #//python/5749

回复 "python处理大数字代码"

这儿你可以回复上面这条便签

captcha