Επεξεργασία

Κοινή χρήση μέσω


factorial_fl()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Calculate factorial.

The function factorial_fl() is a UDF (user-defined function) that calculates factorial of positive integers (n!). It's a simple wrapper of the native gamma() function.

Syntax

factorial_fl(n)

Learn more about syntax conventions.

Parameters

Name Type Required Description
n int ✔️ The input integer for which to calculate the factorial.

Function definition

You can define the function by either embedding its code as a query-defined function, or creating it as a stored function in your database, as follows:

Define the function using the following let statement. No permissions are required.

Important

A let statement can't run on its own. It must be followed by a tabular expression statement. To run a working example of factorial_fl(), see Example.

let factorial_fl=(n:int)
{
    gamma(n+1)
};
// Write your query to use the function here.

Example

let factorial_fl=(n:int)
{
    gamma(n+1)
};
range x from 1 to 10 step 3
| extend fx = factorial_fl(x)

Output

x fx
1 1
4 24
7 5040
10 3628799