Factorial in SQL
Example for versions
PostgreSQL 9.1
The task of factorials calculation is solved using standard methods only: a built-in factorial function !
(postfix form; there is also a prefix form !!
) and a set function generate_series
which generates a set of rows containing values between the first and the second parameters.
select n || '! = ' || (n!)
from generate_series(0,16) as seq(n);
Comments
]]>blog comments powered by Disqus
]]>