# Factorials...How do they do it?

So I've been recently arguing with my teacher about factorials. My teacher says that factorials can only be calculated for integers, because the definition of factorials is as follows:

the product of an integer and all the integers below it

But I've seen many different calculators where you can find the factorials of real numbers, like $5!$, $1.1!$, $-5.7!$, $\sqrt 2!$ or $(\tan 85)!$ and so on...

How do calculators do this? What formula do they use? It's obviously not $(n) \times (n-1) \times \cdots \times 1$ where $n$ is some integer. (In this case it's any real number)

• en.wikipedia.org/wiki/Gamma_function Commented Mar 18, 2015 at 16:34
• "The gamma function is defined for all complex numbers except the negative integers and zero" But I can take factorials of negitive numbers and zeros too! Commented Mar 18, 2015 at 16:35
• @CaptCoonoor It is the "nice" extension of the factorial on the nonnegative integers. It turns out there is not such a "nice" extension which also goes to the negative integers.
– Ian
Commented Mar 18, 2015 at 16:38
• Oh thanks btw, I need to learn integrals first to learn this function till now we have been only taught differential calculus Commented Mar 18, 2015 at 16:39
• @CaptCoonoor: $\Gamma(0)=(-1)!\neq0!=1$. Commented Mar 18, 2015 at 16:47

The calculator is using the gamma function, that satisfies for natural numbers $n$ $$\Gamma(n) = (n-1)!$$ and it is given by $$\Gamma(t) = \int_0^\infty x^{t-1}e^{-x}\,\mathrm{d}x.$$ However, note that when you say $-5.7!$, that means $-(5.7!),$ not $(-5.7)!$.
• Of course. The first one would be $\Gamma(-5.7+1)$, and the second would be $-\Gamma(5.7+1)$. Just like if $f(x) = x^2$ then $f(-2) = 4$, but $-f(2) = -4.$