Advertisement
tpaper

Untitled

Sep 10th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 15.42 KB | None | 0 0
  1. enrico@enrico-desktop:~/Documenti/py$ time (echo "370" | python stir.py ) | bc
  2. .0000000000000000000000000000000000000000000000000000000000000000000\
  3. 00000000000000000000000000000000000000000000000000000000000000000000\
  4. 00000000000000000000000000000000000000000000000000000000000000000000\
  5. 00000000000000000000000000000000000000000000000000000000000000000000\
  6. 00000000000000000000000000000000000000000000000000000000000000000000\
  7. 00000000000000000000000000000000000000000000000000000000000000000000\
  8. 00000000000000000000000000000000000000000000000000000000000000000000\
  9. 00000000000000000000000000000000000000000000000000000000000000000000\
  10. 00000000000000000000000000000000000000000000000000000000000000000000\
  11. 00000000000000000000000000000000000000000000000000000000000000000000\
  12. 00000000000000000000000000000000000000000000000000000000000000000000\
  13. 00000000000000000000000000000000000000000000000000000000000000000000\
  14. 00000000000000000000000000000000000000000000000000000000000000000000\
  15. 00000000000000000000000000000000000000000010278975819208126252741806\
  16. 7277113454651612469596010476344027214109934877628
  17.  
  18. real    0m0.050s
  19. user    0m0.044s
  20. sys     0m0.004s
  21. enrico@enrico-desktop:~/Documenti/py$ time (echo "400" | python stir.py ) | bc
  22. .0000000000000000000000000000000000000000000000000000000000000000000\
  23. 00000000000000000000000000000000000000000000000000000000000000000000\
  24. 00000000000000000000000000000000000000000000000000000000000000000000\
  25. 00000000000000000000000000000000000000000000000000000000000000000000\
  26. 00000000000000000000000000000000000000000000000000000000000000000000\
  27. 00000000000000000000000000000000000000000000000000000000000000000000\
  28. 00000000000000000000000000000000000000000000000000000000000000000000\
  29. 00000000000000000000000000000000000000000000000000000000000000000000\
  30. 00000000000000000000000000000000000000000000000000000000000000000000\
  31. 00000000000000000000000000000000000000000000000000000000000000000000\
  32. 00000000000000000000000000000000000000000000000000000000000000000000\
  33. 00000000000000000000000000000000000000000000000000000000000000000000\
  34. 00000000000000000000000000000000000000000000000000000000000000000000\
  35. 00000000000070557735269639691607297069823223710176858294513690570241\
  36. 7953010303021834427544085462141056021616592478932
  37.  
  38. real    0m0.047s
  39. user    0m0.044s
  40. sys     0m0.000s
  41. enrico@enrico-desktop:~/Documenti/py$ time (echo "600" | python stir.py ) | bc                                                                                                                                                              
  42. .0000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  43. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  44. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  45. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  46. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  47. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  48. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  49. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  50. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  51. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  52. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  53. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  54. 00000000120219848014606841559699576713234914082913173199736222553653\                                                                                                                                                                        
  55. 39148644331571067113914119521280350418857110955094527669916527722318\                                                                                                                                                                        
  56. 2124611979832770379908390654061427917815626485711                                                                                                                                                                                            
  57.                                                                                                                                                                                                                                              
  58. real    0m0.061s                                                                                                                                                                                                                            
  59. user    0m0.052s                                                                                                                                                                                                                            
  60. sys     0m0.004s                                                                                                                                                                                                                            
  61. enrico@enrico-desktop:~/Documenti/py$ time (echo "1500" | python stir.py ) | bc                                                                                                                                                              
  62. .0000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  63. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  64. 00000000000000000000000000000000000000000000000000000000000000000000\                                                                                                                                                                        
  65. 00000000000000000000000000000000000000000000000000000000000000000000\
  66. 00000000000000000000000000000000000000000000000000000000000000000000\
  67. 00000000000000000000000000000000000000000000000000000000000000000000\
  68. 00000000000000000000000000000000000000000000000000000000000000000000\
  69. 00000000000000000000000000000000000000000000000000000000000000000000\
  70. 00000000000000000000000000000000000000000000000000000000000000000000\
  71. 00000000000000000000000000000000000000000000000000000000000000000000\
  72. 00000000000000000000000000000000000000000000000000000000000000000000\
  73. 00000000000000000000000000000000007880310104688594927742533297802833\
  74. 50019472950167445409306429047535425195303871218998213291132864459849\
  75. 70693566060265586825862186633526409987435025331834174787784446439030\
  76. 4672194620645694399383917010383083286026596052170
  77.  
  78. real    0m0.082s
  79. user    0m0.072s
  80. sys     0m0.008s
  81. enrico@enrico-desktop:~/Documenti/py$ time (echo "2300" | python stir.py ) | bc
  82. .0000000000000000000000000000000000000000000000000000000000000000000\
  83. 00000000000000000000000000000000000000000000000000000000000000000000\
  84. 00000000000000000000000000000000000000000000000000000000000000000000\
  85. 00000000000000000000000000000000000000000000000000000000000000000000\
  86. 00000000000000000000000000000000000000000000000000000000000000000000\
  87. 00000000000000000000000000000000000000000000000000000000000000000000\
  88. 00000000000000000000000000000000000000000000000000000000000000000000\
  89. 00000000000000000000000000000000000000000000000000000000000000000000\
  90. 00000000000000000000000000000000000000000000000000000000000000000000\
  91. 00000000000000000000000000000000000000000000000000000000000000000000\
  92. 00000000000000000000000000000000000000000000000000000000000000000000\
  93. 00000000000000000000000000000002042413568386406031257712197828887569\
  94. 90660001255663831725230494942153838025028965439023417386104818440636\
  95. 80940124768091789968417497362700809799379987837125684635011297612394\
  96. 3966884048364258486730959022430666083688754672704
  97.  
  98. real    0m0.096s
  99. user    0m0.084s
  100. sys     0m0.008s
  101. enrico@enrico-desktop:~/Documenti/py$ time (echo "5000" | python stir.py ) | bc
  102. .0000000000000000000000000000000000000000000000000000000000000000000\
  103. 00000000000000000000000000000000000000000000000000000000000000000000\
  104. 00000000000000000000000000000000000000000000000000000000000000000000\
  105. 00000000000000000000000000000000000000000000000000000000000000000000\
  106. 00000000000000000000000000000000000000000000000000000000000000000000\
  107. 00000000000000000000000000000000000000000000000000000000000000000000\
  108. 00000000000000000000000000000000000000000000000000000000000000000000\
  109. 00000000000000000000000000000000000000000000000000000000000000000000\
  110. 00000000000000000000000000000000000000000000000000000000000000000000\
  111. 00000000000000000000000000000000000000000000000000000000000000000000\
  112. 00000000000000000000000000000000000000000000000000000000000000000000\
  113. 00000000000000000000000000000003981805052007088757012195578627065322\
  114. 50618444153392040989938483057049993863199092848716147433631589590778\
  115. 65688809056671046536541000552388217855502540024882822525368944888939\
  116. 3339925295734966268971293100171311525356723300293
  117.  
  118. real    0m0.187s
  119. user    0m0.176s
  120. sys     0m0.008s
  121. enrico@enrico-desktop:~/Documenti/py$ time (echo "10000" | python stir.py ) | bc
  122. .0000000000000000000000000000000000000000000000000000000000000000000\
  123. 00000000000000000000000000000000000000000000000000000000000000000000\
  124. 00000000000000000000000000000000000000000000000000000000000000000000\
  125. 00000000000000000000000000000000000000000000000000000000000000000000\
  126. 00000000000000000000000000000000000000000000000000000000000000000000\
  127. 00000000000000000000000000000000000000000000000000000000000000000000\
  128. 00000000000000000000000000000000000000000000000000000000000000000000\
  129. 00000000000000000000000000000000000000000000000000000000000000000000\
  130. 00000000000000000000000000000000000000000000000000000000000000000000\
  131. 00000000000000000000000000000000000000000000000000000000000000000000\
  132. 00000000000000000000000000000000000000000000000000000000000000000000\
  133. 00000000000000000000000000000003983408516103932464167205865662666967\
  134. 28071413383505964434693958072924327738665285622248048344092567196814\
  135. 51658013472386195191400328738659752465503994167791220287314720443308\
  136. 9875314456467188699360490697226824126361432368926
  137.  
  138. real    0m0.380s
  139. user    0m0.372s
  140. sys     0m0.004s
  141. enrico@enrico-desktop:~/Documenti/py$ time (echo "50000" | python stir.py ) | bc
  142. .0000000000000000000000000000000000000000000000000000000000000000000\
  143. 00000000000000000000000000000000000000000000000000000000000000000000\
  144. 00000000000000000000000000000000000000000000000000000000000000000000\
  145. 00000000000000000000000000000000000000000000000000000000000000000000\
  146. 00000000000000000000000000000000000000000000000000000000000000000000\
  147. 00000000000000000000000000000000000000000000000000000000000000000000\
  148. 00000000000000000000000000000000000000000000000000000000000000000000\
  149. 00000000000000000000000000000000000000000000000000000000000000000000\
  150. 00000000000000000000000000000000000000000000000000000000000000000000\
  151. 00000000000000000000000000000000000000000000000000000000000000000000\
  152. 00000000000000000000000000000000000000000000000000000000000000000000\
  153. 00000000000000000000000000000003983408517872980549687775708738072865\
  154. 47206812807341138634076564803521951613759220127755735231298792340706\
  155. 41815368427921468226288165023061826216593384286014634834848990573149\
  156. 7860487733673863500450776736214257757603341726874
  157.  
  158. real    0m3.453s
  159. user    0m3.440s
  160. sys     0m0.020s
  161. enrico@enrico-desktop:~/Documenti/py$ time (echo "100000" | python stir.py ) | bc
  162. .0000000000000000000000000000000000000000000000000000000000000000000\
  163. 00000000000000000000000000000000000000000000000000000000000000000000\
  164. 00000000000000000000000000000000000000000000000000000000000000000000\
  165. 00000000000000000000000000000000000000000000000000000000000000000000\
  166. 00000000000000000000000000000000000000000000000000000000000000000000\
  167. 00000000000000000000000000000000000000000000000000000000000000000000\
  168. 00000000000000000000000000000000000000000000000000000000000000000000\
  169. 00000000000000000000000000000000000000000000000000000000000000000000\
  170. 00000000000000000000000000000000000000000000000000000000000000000000\
  171. 00000000000000000000000000000000000000000000000000000000000000000000\
  172. 00000000000000000000000000000000000000000000000000000000000000000000\
  173. 00000000000000000000000000000003983408517872980549687775708738072865\
  174. 47206812807341138634464275105748544232731048435781211547376619594013\
  175. 95511793812078914119528661375598980625263147931379446102605294112506\
  176. 5868731796232437117811600923189641235548004412914
  177.  
  178. real    0m10.042s
  179. user    0m10.009s
  180. sys     0m0.028s
  181. enrico@enrico-desktop:~/Documenti/py$ time (echo "1000000" | python stir.py ) | bc
  182. ^[^CTraceback (most recent call last):
  183.   File "stir.py", line 19, in <module>
  184.     print '(',summatory(0,k),'/',math.factorial(k),') /',k**n
  185. KeyboardInterrupt
  186. close failed in file object destructor:
  187. sys.excepthook is missing
  188. lost sys.stderr
  189.  
  190.  
  191. real    6m30.928s
  192. user    6m30.472s
  193. sys     0m0.288s
  194. enrico@enrico-desktop:~/Documenti/py$ cat stir.py
  195. import math
  196.  
  197. global n
  198. global k
  199. n=input('# n (persone)> ')
  200. print n
  201. k=365
  202.  
  203. def cbin(n,k):
  204.         return math.factorial(n)/( math.factorial(k)*math.factorial(n-k)  )
  205.  
  206. def summatory(min,max):
  207.         s = 0
  208.         for j in range(min,max+1):
  209.                 s += ((-1)**(k-j))*cbin(k,j)*(j**n)
  210.         return s
  211.  
  212. print 'scale=1000'
  213. print '(',summatory(0,k),'/',math.factorial(k),') /',k**n
  214. enrico@enrico-desktop:~/Documenti/py$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement