Skip to main content
`Ctrl`+`K`

# scipy.special.factorial2

scipy.special.factorial2(n, exact=False)

  Double factorial.

  This is the factorial with every second value skipped. E.g., `7!! = 7 * 5 * 3 * 1`. It can be approximated numerically as:

      n!! = 2 ** (n / 2) * gamma(n / 2 + 1) * sqrt(2 / pi)  n odd
          = 2 ** (n / 2) * gamma(n / 2 + 1)                 n even
          = 2 ** (n / 2) * (n / 2)!                         n even

  Parameters:
    n int or array_like

      Calculate `n!!`. If `n < 0`, the return value is 0.

    exact bool, optional

      The result can be approximated rapidly using the gamma-formula above (default). If exact is set to True, calculate the answer exactly using integer arithmetic.

  Returns:
    nff float or int

      Double factorial of n, as an int or a float depending on exact.

  Examples

      >>> from scipy.special import factorial2
      >>> factorial2(7, exact=False)
      array(105.00000000000001)
      >>> factorial2(7, exact=True)
      105