Just for the sake of variety, here's a LuaLaTeX-based solution.

The froac function produces an overflow for n>20. While n>20 may seem to be a rather poor overflow threshold, do observe that the \froac:n macros in (a) @MarcelKrüger's answer and (b) @UlrichDiez's answer both have a far more stringent overflow threshold: n>12.
\documentclass{article}
\directlua{
%% Define a Lua function called 'froac'
function froac ( n )
if n==0 or n==1 then return 1
else return n * froac ( n-1 )
end
end
}
%% Define a LaTeX wrapper macro called '\froac'
\newcommand\froac[1]{\directlua{tex.sprint(froac(#1))}}
\begin{document}
$\begin{array}{rr}
\directlua { for i = 0 , 20 do
tex.sprint ( i .. "&" .. froac ( i ) .. "\\" )
end }
\end{array}$
\end{document}
Addendum/Remark: Even though the usual, i.e., recursive, definition of the factorial function counts down from n to 0 (or 1), it is actually more efficient, computationally speaking, to count up to n. Doing so allows us to evaluate the if n==0 condition just once at the start of the routine, and then to perform a deterministic for loop over a range of integers. In Lua, this idea might be implemented as follows:
-- Define 'froac' by counting _up_ rather than down
function froac(n)
if n==0 or n==1 then return 1
else f=2; for i=3,n do f=f*i end; return f
end
end
#1things work:\int_eval:n{(#1)*\froac:n{#1-1}}. – Peter Grill Dec 08 '21 at 00:59l3fpsupports a factorial functionfact:\fp_eval:n { fact( ⟨fpexpr⟩ ) }. It works for integers between 0 and 3248. – muzimuzhi Z Dec 08 '21 at 04:58factroutine of thel3fppackage possess? – Mico Dec 08 '21 at 12:58texdoc interface3(2021-11-22), sec. 28.9.1 "Input of floating point numbers" – muzimuzhi Z Dec 08 '21 at 16:17