{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"factorial"},"result":{"entity_type":"calculator","id":"factorial","calculator_id":"factorial","canonical_url":"https://tttkmbb.com/math/factorial","name":"Factorial Calculator","title":"Factorial Calculator – n! with Digit Count, Trailing Zeros and Scientific Notation","category":"math","category_name":"Math","tool_name":"calculate_factorial","featured_mcp_tool":false,"description":"Computes n! = 1 × 2 × … × n for integers from 0 to 170, together with the number of decimal digits, the number of trailing zeros and a scientific-notation form.","use_when":"You need the factorial of an integer, e.g. for counting arrangements or as a building block of permutations and combinations.","do_not_use_when":"n exceeds 170 (the result overflows double precision; use Stirling's approximation or log-gamma) or you need C(n, k) / P(n, k) directly (use combinations-permutations).","inputs":[{"name":"n","label":"n","type":"integer","required":true,"min":0,"max":170,"description":"Non-negative integer up to 170.","example":5}],"outputs":[{"name":"factorial","label":"n!","type":"number","decimals":0,"description":"The factorial. Exact up to 22!; above that correct to about 16 significant digits."},{"name":"digits","label":"Number of digits","type":"integer","decimals":0,"description":"Decimal digits of n!: ⌊log10(n!)⌋ + 1."},{"name":"trailing_zeros","label":"Trailing zeros","type":"integer","decimals":0,"description":"Zeros at the end of n! (Legendre's formula: ⌊n/5⌋ + ⌊n/25⌋ + …)."},{"name":"scientific_notation","label":"Scientific notation","type":"string","decimals":4,"description":"n! with 5 significant digits, e.g. '2.4329 × 10^18'."}],"input_schema":{"type":"object","properties":{"n":{"description":"Non-negative integer up to 170.","type":"integer","minimum":0,"maximum":170,"examples":[5]}},"additionalProperties":false,"required":["n"]},"output_schema":{"type":"object","properties":{"factorial":{"description":"The factorial. Exact up to 22!; above that correct to about 16 significant digits.","type":"number"},"digits":{"description":"Decimal digits of n!: ⌊log10(n!)⌋ + 1.","type":"integer"},"trailing_zeros":{"description":"Zeros at the end of n! (Legendre's formula: ⌊n/5⌋ + ⌊n/25⌋ + …).","type":"integer"},"scientific_notation":{"description":"n! with 5 significant digits, e.g. '2.4329 × 10^18'.","type":"string"}}},"formula":"n! = n × (n − 1) × … × 2 × 1, with 0! = 1; digits = ⌊Σ log10(i)⌋ + 1; trailing_zeros = Σ ⌊n / 5^k⌋","sources":[{"name":"Wikipedia – Factorial","url":"https://en.wikipedia.org/wiki/Factorial","type":"reference","retrieved_at":"2026-09-23"},{"name":"NIST Digital Library of Mathematical Functions §5.2 – Gamma function: definitions (n! = Γ(n + 1))","url":"https://dlmf.nist.gov/5.2","type":"standard","retrieved_at":"2026-09-23"},{"name":"Wolfram MathWorld – Factorial","url":"https://mathworld.wolfram.com/Factorial.html","type":"reference","retrieved_at":"2026-09-23"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"5!","inputs":{"n":5},"expected":{"factorial":120,"digits":3,"trailing_zeros":1,"scientific_notation":"1.2 × 10^2"},"url":"https://tttkmbb.com/api/v1/calculate/factorial?n=5"},{"name":"20!","inputs":{"n":20},"expected":{"factorial":2432902008176640000,"digits":19,"trailing_zeros":4,"scientific_notation":"2.4329 × 10^18"},"url":"https://tttkmbb.com/api/v1/calculate/factorial?n=20"}],"faq":[{"q":"Why is 0! equal to 1?","a":"By definition (the empty product), which keeps the recurrence n! = n × (n − 1)! and the counting formulas consistent."},{"q":"Is the result exact?","a":"Up to 22! every digit is exact. From 23! on the value has more than 53 significant bits, so only the first ~16 significant digits are reliable; the digit and trailing-zero counts stay exact."}],"tags":["factorial","n factorial","n!","trailing zeros","how many digits"],"related":[{"calculator_id":"combinations-permutations","reason":"Counts of selections and arrangements built from factorials."},{"calculator_id":"exponent","reason":"Powers, the other fast-growing product."}],"links":{"html":"https://tttkmbb.com/math/factorial","markdown":"https://tttkmbb.com/math/factorial.md","json":"https://tttkmbb.com/math/factorial.json","api":"https://tttkmbb.com/api/v1/calculate/factorial","schema":"https://tttkmbb.com/api/v1/calculators/factorial","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-23"},"timestamp":"2026-09-23T23:23:13Z"}