The pi function — calculating factorials using integration

Martin McBride
Graphic maths
Published in
9 min readJul 5, 2024


The factorial function n!, is a well-known function that has many applications in mathematics. It is defined for non-negative integers as:

The normal definition of the factorial defines a process for calculating n!. You must multiply together every integer from 1 to n. In the early 18th century, Euler and several other mathematicians attempted to find a function that would return the value of n! when passed any non-negative integer n.

The answer they came up with was the pi function Π(x) (nothing to do with the mathematical constant 3.14…, pi is just the Greek letter, it is capital form Π). This function has been largely consigned to history since Euler invented the gamma function shortly afterwards. But it is still interesting, firstly because it was a crucial step to finding the gamma function, and secondly because it is very clever in its own right.

So the requirement of the pi function is that:

For all non-negative integer values of x.

There is no obvious function that meets this specification, it required a bit of creative thinking.

The pi function

Euler and his collaborators discovered a function that fits the bill. Here is the pi function, which can be used to find the…