{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "While less straight-forward than for the double-factorial, it's possible to calculate a general approximation formula of n!(k) by studying "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for a given remainder "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r < k"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (thus "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n = m * k + r"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", resp. "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r = n % k"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), which can be put together into something valid for all integer values "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n >= 0"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " & "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "k > 0"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "n!(k) = k ** ((n - r)/k) * gamma(n/k + 1) / gamma(r/k + 1) * max(r, 1)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This is the basis of the approximation when "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "exact=False"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In principle, any fixed choice of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (ignoring its relation "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r = n%k"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") would provide a suitable analytic continuation from integer "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to complex "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "z"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (not only satisfying the functional equation but also being logarithmically convex, c.f. Bohr-Mollerup theorem) -- in fact, the choice of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " above only changes the function by a constant factor. The final constraint that determines the canonical continuation is "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "f(1) = 1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", which forces "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r = 1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (see also [1]).    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "z!(k) = k ** ((z - 1)/k) * gamma(z/k + 1) / gamma(1/k + 1)",
          "execution_status": null
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nf",
              "annotation": "int or float or complex or ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Multifactorial (order "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "k"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ") of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "n"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", as integer, float or complex (depending on "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "exact"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "extend"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "). Array inputs are returned as arrays."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Multifactorial of n of order k, n(!!...!)."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "n",
              "annotation": "int or float or complex (or array_like thereof)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Input values for multifactorial. Non-integer values require "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "extend='complex'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". By default, the return value for "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "n < 0"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is 0."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "k",
              "annotation": "int or float or complex (or array_like thereof)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Order of multifactorial. Non-integer values require "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "extend='complex'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "exact",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "exact"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is set to True, calculate the answer exactly using integer arithmetic, otherwise use an approximation (faster, but yields floats instead of integers) Default is False."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "extend",
              "annotation": "string, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "One of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'zero'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'complex'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "; this determines how values "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "n<0"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are handled - by default they are 0, but it is possible to opt into the complex extension of the multifactorial. This enables passing complex values, not only to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "n"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " but also to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "k"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                },
                {
                  "__type": "Admonition",
                  "__tag": 4056,
                  "kind": "warning",
                  "base_type": "warning",
                  "children": [
                    {
                      "__type": "AdmonitionTitle",
                      "__tag": 4055,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "warning "
                        }
                      ]
                    },
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Using the "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "'complex'"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " extension also changes the values of the multifactorial at integers "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "n != 1 (mod k)"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " by a factor depending on both "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "k"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " and "
                        },
                        {
                          "__type": "InlineCode",
                          "__tag": 4051,
                          "value": "n % k"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", see below or [1]."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This is the multifactorial of n skipping k values.  For example,"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "factorialk(17, 4) = 17!!!! = 17 * 13 * 9 * 5 * 1"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In particular, for any integer "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", we have"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "factorialk(n, 1) = factorial(n)"
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "factorialk(n, 2) = factorial2(n)"
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/special/_basic.py",
  "item_line": 3052,
  "item_type": "function",
  "aliases": [
    "scipy.special.factorialk"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.special import factorialk\nfactorialk(5, k=1, exact=True)\nfactorialk(5, k=3, exact=True)\nfactorialk([5, 7, 9], k=3, exact=True)\nfactorialk([5, 7, 9], k=3, exact=False)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "n",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "k",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "exact",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "extend",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "zero"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "factorialk"
  },
  "references": [
    ".. [1] Complex extension to multifactorial",
    "        https://en.wikipedia.org/wiki/Double_factorial#Alternative_extension_of_the_multifactorial"
  ],
  "qa": "scipy.special._basic:factorialk",
  "arbitrary": [],
  "local_refs": [
    "exact",
    "extend",
    "k",
    "n",
    "nf"
  ]
}