{
  "id": "prime-factorization",
  "version": "d43c5d6aa29f",
  "status": "published",
  "name": "Prime Factorization Calculator",
  "question": "What is the prime factorization?",
  "summary": "Writes a whole number from 2 to 9,007,199,254,740,991 as a product of primes, in exponent form and written out, with its distinct prime factors and number of divisors.",
  "category": "math",
  "subcategory": "arithmetic",
  "url": "https://www.acalculator.org/math/prime-factorization-calculator",
  "markdown": "https://www.acalculator.org/math/prime-factorization-calculator.md",
  "kind": "function",
  "method": "Divide by primes up to 1,000; test what is left with Miller–Rabin and split it with Pollard’s rho until every factor is prime.",
  "assumptions": [
    "The number is a whole number from 2 to 9,007,199,254,740,991 (2⁵³ − 1), the largest whole number a double holds exactly.",
    "1 is not prime and has no prime factorization; every whole number from 2 up has exactly one."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "n": {
        "title": "Number",
        "description": "A whole number from 2 to 9,007,199,254,740,991 (2⁵³ − 1).",
        "type": "integer",
        "minimum": 2,
        "maximum": 9007199254740991
      }
    }
  },
  "outputs": {
    "factorization": {
      "label": "Prime factorization",
      "description": "The number as a product of prime powers, smallest prime first.",
      "format": "text"
    },
    "expanded": {
      "label": "Written out",
      "description": "Every prime factor repeated, smallest first (at most 52, for 2⁵²).",
      "format": "text"
    },
    "primes": {
      "label": "Distinct prime factors",
      "description": "Each prime that divides the number, once.",
      "format": "text"
    },
    "prime": {
      "label": "Is it prime?",
      "description": "Yes when the number’s only prime factor is itself.",
      "format": "text"
    },
    "count": {
      "label": "Prime factors (with repeats)",
      "description": "The sum of the exponents.",
      "format": "integer"
    },
    "divisors": {
      "label": "Number of divisors",
      "description": "The product of (exponent + 1) over the prime factors.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "n": 360
    },
    "outputs": {
      "factorization": "2³ × 3² × 5",
      "expanded": "2 × 2 × 2 × 3 × 3 × 5",
      "primes": "2, 3, 5",
      "prime": "No, it is composite",
      "count": 6,
      "divisors": 24
    },
    "text": "The prime factorization of 360 is 2³ × 3² × 5."
  },
  "examples": [
    {
      "given": {
        "n": 48
      },
      "expect": {
        "factorization": "2⁴ × 3",
        "expanded": "2 × 2 × 2 × 2 × 3",
        "count": 5,
        "divisors": 10
      },
      "source": "OpenStax, Prealgebra 2e, §2.5 Prime Factorization and the Least Common Multiple (the prime factorization of a number is the product of prime numbers that equals the number; 48 = 2⁴ × 3, 84 = 2² × 3 × 7, 120 = 2³ × 3 × 5), https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple (retrieved 2026-10-02)"
    },
    {
      "given": {
        "n": 84
      },
      "expect": {
        "factorization": "2² × 3 × 7",
        "primes": "2, 3, 7",
        "divisors": 12
      },
      "source": "OpenStax, Prealgebra 2e, §2.5 Prime Factorization and the Least Common Multiple (the prime factorization of a number is the product of prime numbers that equals the number; 48 = 2⁴ × 3, 84 = 2² × 3 × 7, 120 = 2³ × 3 × 5), https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple (retrieved 2026-10-02)"
    },
    {
      "given": {
        "n": 360
      },
      "expect": {
        "factorization": "2³ × 3² × 5",
        "expanded": "2 × 2 × 2 × 3 × 3 × 5",
        "divisors": 24
      },
      "source": "hand calculation in content.mdx: 360 = 2 × 180 = 2 × 2 × 90 = 2 × 2 × 2 × 45 = 2³ × 3² × 5; OpenStax, Prealgebra 2e, §2.5 Prime Factorization and the Least Common Multiple (the prime factorization of a number is the product of prime numbers that equals the number; 48 = 2⁴ × 3, 84 = 2² × 3 × 7, 120 = 2³ × 3 × 5), https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple (retrieved 2026-10-02)"
    },
    {
      "given": {
        "n": 9007199254740991
      },
      "expect": {
        "factorization": "6,361 × 69,431 × 20,394,401",
        "count": 3,
        "divisors": 8
      },
      "source": "hand calculation in content.mdx: 6,361 × 69,431 = 441,650,591, × 20,394,401 = 9,007,199,254,740,991; OpenStax, Prealgebra 2e, §2.5 Prime Factorization and the Least Common Multiple (the prime factorization of a number is the product of prime numbers that equals the number; 48 = 2⁴ × 3, 84 = 2² × 3 × 7, 120 = 2³ × 3 × 5), https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple (retrieved 2026-10-02); Python 3 trial division"
    },
    {
      "given": {
        "n": 9007199254740881
      },
      "expect": {
        "factorization": "9,007,199,254,740,881",
        "prime": "Yes, it is prime",
        "divisors": 2
      },
      "source": "hand calculation in content.mdx: no prime up to √n ≈ 94,906,265 divides it; OpenStax, Prealgebra 2e, §2.5 Prime Factorization and the Least Common Multiple (the prime factorization of a number is the product of prime numbers that equals the number; 48 = 2⁴ × 3, 84 = 2² × 3 × 7, 120 = 2³ × 3 × 5), https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple (retrieved 2026-10-02); Python 3 trial division"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, §2.5 Prime Factorization and the Least Common Multiple (definition; the factor tree and ladder methods; 48 = 2⁴ × 3, 84 = 2² × 3 × 7, 120 = 2³ × 3 × 5). https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple (retrieved 2026-10-02)"
  ],
  "related": [
    "factor",
    "gcf",
    "lcm"
  ],
  "changelog": []
}
