# LGF_GetFactorial (FC / 3.0.1)

Overview

Author: Siemens Digital Industry

## Short description

The function calculates the faculty of a natural number (\mathbb{N}!) and returns the result.

The permissible value range of the input parameter `naturalNumber` is between 0 and 12, as 12 is the maximum factorial result fitting into a DInt type

### Block Interface

| LGF_GetFactorial (FC) |
--- | --- | ---
Int |  |  | naturalNumber |  | Ret_Val |  |  | DInt
|  |  |  |  | error |  |  | Bool
|  |  |  |  | status |  |  | Word

### Input parameter

Identifier | Data type | Description
--- | --- | ---
naturalNumber | Int | Natural number (0..12)

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | DInt | Calculated factorial
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table)

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_NO_ERROR Execution finished without errors
16#8101 | ERR_WRONG_VALUE_RANGE Error: Input value out of range Permissible value range is 0..12

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 03.07.2018 | First released version
| 1.0.1 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 1.0.2 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 1.1.0 | Siemens Industry Online Support
| 23.09.2019 | Renamed from "Factorial" to "GetFactorial" Code refactoring, regions and more comments added Reworked to case of, MAGIC numbers are okay as they stay for the number/case itself
| 3.0.0 | Siemens Industry Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 3.0.1 | Simatic Systems Support
| 12.11.2020 | Insert documentation