factorial property

int factorial

Calculates the factorial of the integer.

The factorial is defined as the product of all positive integers up to and including the integer itself. By definition, the factorial of 0 is 1, which serves as the base case for this recursive relationship.

Returns the factorial value. Note that due to using the int type, the result may be subject to integer overflow limitations, especially with larger numbers.

Implementation

int get factorial =>
    this == 0 ? 1 : List.generate(toInt(), (index) => index + 1).reduce((value, element) => value * element);