Algorithm number e

Quote: Baidu Encyclopedia passage;

E, as a mathematical constant, is a function of the natural logarithm base number . Sometimes called Euler's number (Euler number), to Swiss mathematician Euler named; also has a relatively uncommon name Napier constant , to commemorate the Scottish mathematician John Napier  (John Napier) the introduction of number. It is like pi π and the imaginary unit i, e is the most important mathematical constant one.
Wherein it is defined a
   
Whose value is about (100 decimal): "e ≈ 2.71828 18284 59045 23536 02874 71352 66249 77572 47093 69995 95749 66967 62772 40766 30353 54759 45713 82178 52516 64274".
 
 
. 1  DEF fun_e (n-):
 2      SUM = 0
 . 3      
. 4      SUM + = (. 1. 1 + / n-) ** n-
 . 5              
. 6      return SUM
 . 7  Print (fun_e (620 000 000 ))
 . 8     
# Results: 2.7182816890306443
1 def fun_e (n):
2     sum = 1
3     s = 1
4     for i in range(1,n+1):
5         for j in range(1,i+1):
6             s = s*j
7         sum += 1/s
8     return sum
9 print(fun_e(1000))

#结果:2.5868345309364718

Temporary use of these two algorithms

 

Guess you like

Origin www.cnblogs.com/xiaoliangliu86/p/11367200.html