Logo

FACTORIALPOWER

Updated 2024-03-07 21:40:49.020000

Syntax

SELECT [westclintech].[wct].[FACTORIALPOWER] (
   <@x, int,>
  ,<@n, int,>
  ,<@h, int,>)

Description

Use the SQL Server scalar function FACTORIALPOWER to calculate the step-h factorial power x(n,h).

x^{(n,h)}=x(x-h)(x-2h)\dots(x-(n-1)h)

Arguments

@x

Number of interest.

@n

Number of steps.

@h

Step-size.

Return Type

float

Remarks

If h > 0 then the falling factorial is returned.

If h < 0 then the rising factorial is returned.

If x, h or n is NULL, then an error is returned.

Examples

Example #1

SELECT n.h,

       wct.FACTORIALPOWER(25, 8, n.h) as FactorialPower

FROM

(

    VALUES

        (-3),

        (-2),

        (-1),

        (0),

        (1),

        (2),

        (3)

) n (h);

This produces the following result.

{"columns":[{"field":"h","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"FactorialPower","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"h":"-3","FactorialPower":"2159865232000"},{"h":"-2","FactorialPower":"1011373988625"},{"h":"-1","FactorialPower":"424097856000"},{"h":"0","FactorialPower":"152587890625"},{"h":"1","FactorialPower":"43609104000"},{"h":"2","FactorialPower":"8365982625"},{"h":"3","FactorialPower":"608608000"}]}

See Also

FACT - factorial of a number

FACTLN - natural logarithm of a factorial

GAMMA - complete gamma function

GAMMALN - natural logarithm of the complete gamma function