This function is only working with
natural numbers (0..infinity)
For this range your function is working fine.
But this could not calculate
all the real numbers like -6, -8.323, 0.5 etc.
If you go to
Mathematical Department in university or
Mechanical Engineering or
Electric-Electronic Engineering in the lesson
Differential Equations or
Laplace, you must learn that we have learnt the factorial function wrong before.
Until high school the teachers teach us wrong that factorial works with only 0,1,2...infinity.
Actually factorial works with all real numbers.For example:
factorial(2) = 2
factorial(4) = 24
factorial(5) = 120
and also
factorial(1/2)=factorial(0.5)= sqrt(pi) =~ 1,77245385If you don't believe me go to a mathematic professor in a university and ask him, factorial(1/2)?
By the way the formula of factorial is
n! = integral[0 to infinity] (t^(n-1)) * e^(-t) * dtI couldn't write the integral symbol so I wrote: integral[0 to infinity]
I found a picture from wikipedia
//Edit reason: the formula inserted
Reply