factorial(n)

..  factorial(n)

Factorial of ``n``.  If ``n`` is an :obj:`Integer`, the factorial
is computed as an integer (promoted to at least 64 bits).  Note
that this may overflow if ``n`` is not small, but you can use
``factorial(big(n))`` to compute the result exactly in arbitrary
precision.  If ``n`` is not an ``Integer``, ``factorial(n)`` is
equivalent to :func:`gamma(n+1) <gamma>`.

Examples

julia> factorial(4)
24
julia> factorial(3)
6
julia> factorial(2)
2
julia> factorial(3,2)
3

The factorial(n, k) function in Julia computes the ratio of factorials, (factorial(n) / factorial(k)).

Here are some examples of how to use the factorial(n, k) function:

  1. Compute the ratio of factorials:

    julia> factorial(6, 3)
    120.0

    This example calculates the ratio (factorial(6) / factorial(3)), which equals 120.0.

  2. Calculate the ratio for larger values:

    julia> factorial(10, 5)
    30240.0

    It computes the ratio (factorial(10) / factorial(5)), resulting in 30240.0.

  3. Handle edge cases:

    julia> factorial(0, 0)
    1.0

    In this case, both n and k are zero, so the ratio is 1.0.

    julia> factorial(5, 10)
    0.0

    Here, k is greater than n, so the ratio is 0.0.

Please note that the factorial(n, k) function returns a floating-point value.

Remember to provide valid inputs and ensure that k <= n to avoid errors and obtain meaningful results.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: