Advertisement
Azgarok

Untitled

Jul 28th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function fact(z)
  2. z=z+1
  3. local m=math
  4. local pi,e,f=m.pi,m.exp(1),m.floor
  5. local g = 7
  6. local p = {0.99999999999980993, 676.5203681218851, -1259.1392167224028,
  7. 771.32342877765313, -176.61502916214059, 12.507343278686905,
  8. -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7}
  9. if z<0.5 then
  10. if z<0 and f(z)==z then return m.huge end
  11. return pi/(m.sin(pi*z)*fact(-z))
  12. else
  13. z=z-1
  14. x=p[1]
  15. for i=1,g+1 do
  16. x=x+p[i+1]/(z+i)
  17. end
  18. t=z+g+0.5;r=m.sqrt(2*pi)*m.pow(t,z+0.5)*m.exp(-t)*x
  19. return (f(z)==z) and f(r) or r
  20. end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement