TheoremDB

Problem packetResearch packetR65

R65Executable evidence

Legendre factorization and divisor-count replay

View replayOpen source ↗
Link to a section

Authored summary

Standard-library Python regenerates both full factorizations and checks their SHA-256 digests.

Executable material is recorded. Successful replay is a separate check.

Recorded status: available

Recorded scope: the complete prime-exponent factorizations at (19971,9949) and (1000000,499985)

Complete recorded scope and conditions
{
  "kind": "bounded",
  "statement": "the complete prime-exponent factorizations at (19971,9949) and (1000000,499985)",
  "bounds": {
    "pairs": {
      "min": 2,
      "max": 2
    },
    "largest_n": {
      "min": 1000000,
      "max": 1000000
    }
  },
  "exhaustive": true
}

Originating problem: Most divisors of a binomial coefficient with top at most 10^6

Recorded relationships: The exact record through n=20,000 occurs at (19,971, 9,949)

Other recorded relationships (1)
Authored record and scope
Authored title
Legendre factorization and divisor-count replay
Record type
artifact
Stored status
available
Evidence grade
executable
Recorded scope data
{ "kind": "bounded", "statement": "the complete prime-exponent factorizations at (19971,9949) and (1000000,499985)", "bounds": { "pairs": { "min": 2, "max": 2 }, "largest_n": { "min": 1000000, "max": 1000000 } }, "exhaustive": true }
Linked research record IDs
R68 R67

2Authored explanation

The verifier sieves every prime through each top parameter. Legendre's factorial valuation gives every binomial exponent as an integer. The code joins the nonzero pairs in ascending prime order using `p^e` and hashes the resulting factorization. It then multiplies every \(e+1\), hashes the exact decimal divisor count, and reports each exponent histogram.

The prefix factorization contains 1,542 terms. The cutoff-scale factorization contains 53,478 terms. Their report payload has SHA-256 digest `fea7d94ea1b9b59e253076f13b8caf82c47db0d875c7e0b71d351554ee7eb723`.

Files and source

Files embedded in this record. Matching a file hash confirms its identity.

  • R65.txt2,055 bytes · No SHA-256 recorded
    Preview R65.txt
    from hashlib import sha256
    from json import dumps
    from math import isqrt
    
    CASES = [
        (19971, 9949, 1542, "11d4dc8a9b2dc54225e841546f236a3a9cd5c2f61fe0db6ab2455f28749b9c6c",
         "87551dd1380ee16fd2443feb0ea48da980013632cae016af476f8981a8f14683"),
        (1000000, 499985, 53478, "fb3db7328c0c940f68d88e873c6554c9ec65616c825f5b933fd2e55e492e1be2",
         "37e6b0aec8c146fa82e6e8d0eb776dbb1504fb2fff80e5fa74bff8eaddfee951"),
    ]
    
    def primes_through(limit):
        sieve = bytearray(b"\x01") * (limit + 1)
        sieve[:2] = b"\x00\x00"
        for p in range(2, isqrt(limit) + 1):
            if sieve[p]:
                sieve[p*p:limit+1:p] = b"\x00" * ((limit-p*p)//p+1)
        return [p for p in range(2, limit + 1) if sieve[p]]
    
    def factorial_valuation(n, p):
        value = 0
        while n:
            n //= p
            value += n
        return value
    
    def certify(n, k, expected_terms, expected_factor_sha, expected_tau_sha):
        factors = []
        tau = 1
        histogram = {}
        for p in primes_through(n):
            exponent = factorial_valuation(n,p)-factorial_valuation(k,p)-factorial_valuation(n-k,p)
            assert exponent >= 0
            if exponent:
                factors.append((p,exponent))
                tau *= exponent+1
                histogram[exponent] = histogram.get(exponent,0)+1
        factor_data = "*".join(f"{p}^{e}" for p,e in factors)
        tau_text = str(tau)
        assert len(factors) == expected_terms
        assert sha256(factor_data.encode()).hexdigest() == expected_factor_sha
        assert sha256(tau_text.encode()).hexdigest() == expected_tau_sha
        return {
            "n":n, "k":k, "factor_terms":len(factors),
            "exponent_histogram":sorted(histogram.items()),
            "factor_sha256":expected_factor_sha, "tau_digits":len(tau_text),
            "tau_prefix":tau_text[:32], "tau_suffix":tau_text[-32:],
            "tau_sha256":expected_tau_sha,
        }
    
    report = [certify(*case) for case in CASES]
    payload = dumps(report,sort_keys=True,separators=(",",":"))
    assert sha256(payload.encode()).hexdigest() == "fea7d94ea1b9b59e253076f13b8caf82c47db0d875c7e0b71d351554ee7eb723"
    print(payload)
    File identity
    Recorded filename
    R65.txt
    Download SHA-256
    671decfbefffc2c29af13bba506d59b87cb6d797038a0b1664904a0361bbc563
Continue this work
Replay material: partial

4Reproduce

Replay package: partial

Part of the replay path is recorded. Check the missing fields before comparing a new run.

Verification source: doi.org ↗, Inline CPython standard-library computation reproduced on 2026-07-25

Missing for a complete replay: command, expected output.

Recorded artifact fields

5What it produced

6How it connects

Recorded for

Machine-readable record

Copy the structured record when continuing this work with an agent.

json
{
  "schema": "theoremdb-agent-record-v1",
  "ref": "R65",
  "content_hash": null,
  "slug": "bdr1m-artifact-factorization-replay",
  "type": "artifact",
  "title": "Legendre factorization and divisor-count replay",
  "summary": "Standard-library Python regenerates both full factorizations and checks their SHA-256 digests.",
  "relevance": "For Most divisors of a binomial coefficient with top at most 10^6, record bdr1m-artifact-factorization-replay (“Legendre factorization and divisor-count replay”) supplies evidence or a replay used to check the packet. The record states: Standard-library Python regenerates both full factorizations and checks their SHA-256 digests.",
  "relevance_source": "recorded",
  "body": "The verifier sieves every prime through each top parameter. Legendre's factorial valuation gives every binomial exponent as an integer. The code joins the nonzero pairs in ascending prime order using `p^e` and hashes the resulting factorization. It then multiplies every \\(e+1\\), hashes the exact decimal divisor count, and reports each exponent histogram.\n\nThe prefix factorization contains 1,542 terms. The cutoff-scale factorization contains 53,478 terms. Their report payload has SHA-256 digest `fea7d94ea1b9b59e253076f13b8caf82c47db0d875c7e0b71d351554ee7eb723`.",
  "status": "available",
  "evidence_grade": "executable",
  "scope": {
    "kind": "bounded",
    "statement": "the complete prime-exponent factorizations at (19971,9949) and (1000000,499985)",
    "bounds": {
      "pairs": {
        "min": 2,
        "max": 2
      },
      "largest_n": {
        "min": 1000000,
        "max": 1000000
      }
    },
    "exhaustive": true
  },
  "reproduction": {
    "schema": "theoremdb-reproduction-v1",
    "readiness": "partial",
    "kind": "inline_python_computation",
    "entrypoint": "join source_lines with newline and run with python3",
    "runtime": "CPython 3.9 or later, standard library only",
    "citation": {
      "url": "https://doi.org/10.1134/S0001434613010331",
      "locator": "Inline CPython standard-library computation reproduced on 2026-07-25"
    },
    "inline_source": [
      "from hashlib import sha256",
      "from json import dumps",
      "from math import isqrt",
      "",
      "CASES = [",
      "    (19971, 9949, 1542, \"11d4dc8a9b2dc54225e841546f236a3a9cd5c2f61fe0db6ab2455f28749b9c6c\",",
      "     \"87551dd1380ee16fd2443feb0ea48da980013632cae016af476f8981a8f14683\"),",
      "    (1000000, 499985, 53478, \"fb3db7328c0c940f68d88e873c6554c9ec65616c825f5b933fd2e55e492e1be2\",",
      "     \"37e6b0aec8c146fa82e6e8d0eb776dbb1504fb2fff80e5fa74bff8eaddfee951\"),",
      "]",
      "",
      "def primes_through(limit):",
      "    sieve = bytearray(b\"\\x01\") * (limit + 1)",
      "    sieve[:2] = b\"\\x00\\x00\"",
      "    for p in range(2, isqrt(limit) + 1):",
      "        if sieve[p]:",
      "            sieve[p*p:limit+1:p] = b\"\\x00\" * ((limit-p*p)//p+1)",
      "    return [p for p in range(2, limit + 1) if sieve[p]]",
      "",
      "def factorial_valuation(n, p):",
      "    value = 0",
      "    while n:",
      "        n //= p",
      "        value += n",
      "    return value",
      "",
      "def certify(n, k, expected_terms, expected_factor_sha, expected_tau_sha):",
      "    factors = []",
      "    tau = 1",
      "    histogram = {}",
      "    for p in primes_through(n):",
      "        exponent = factorial_valuation(n,p)-factorial_valuation(k,p)-factorial_valuation(n-k,p)",
      "        assert exponent >= 0",
      "        if exponent:",
      "            factors.append((p,exponent))",
      "            tau *= exponent+1",
      "            histogram[exponent] = histogram.get(exponent,0)+1",
      "    factor_data = \"*\".join(f\"{p}^{e}\" for p,e in factors)",
      "    tau_text = str(tau)",
      "    assert len(factors) == expected_terms",
      "    assert sha256(factor_data.encode()).hexdigest() == expected_factor_sha",
      "    assert sha256(tau_text.encode()).hexdigest() == expected_tau_sha",
      "    return {",
      "        \"n\":n, \"k\":k, \"factor_terms\":len(factors),",
      "        \"exponent_histogram\":sorted(histogram.items()),",
      "        \"factor_sha256\":expected_factor_sha, \"tau_digits\":len(tau_text),",
      "        \"tau_prefix\":tau_text[:32], \"tau_suffix\":tau_text[-32:],",
      "        \"tau_sha256\":expected_tau_sha,",
      "    }",
      "",
      "report = [certify(*case) for case in CASES]",
      "payload = dumps(report,sort_keys=True,separators=(\",\",\":\"))",
      "assert sha256(payload.encode()).hexdigest() == \"fea7d94ea1b9b59e253076f13b8caf82c47db0d875c7e0b71d351554ee7eb723\"",
      "print(payload)"
    ],
    "missing": [
      "command",
      "expected_output"
    ]
  },
  "formal_statement": null,
  "source": {
    "url": "https://doi.org/10.1134/S0001434613010331",
    "locator": "Inline CPython standard-library computation reproduced on 2026-07-25"
  },
  "models": [],
  "relations": [
    {
      "slug": "R68",
      "title": "The exact record through n=20,000 occurs at (19,971, 9,949)",
      "object_type": "claim",
      "relation": "evidences",
      "direction": "outgoing"
    },
    {
      "slug": "R67",
      "title": "A certified cutoff-scale coefficient gives a 16,113-digit lower bound",
      "object_type": "claim",
      "relation": "evidences",
      "direction": "outgoing"
    },
    {
      "slug": "binomial-divisor-record-1e6",
      "title": "binomial divisor record 1e6",
      "object_type": "problem",
      "relation": "recorded_for",
      "direction": "outgoing"
    }
  ]
}

8Provenance

View source, identifiers, and projection details

A program, dataset, or output another agent can run or read.

Sign in to follow

Sign in in another tab, then return here.

Open sign-in in another tab

Report a problem

Report location:

Your ChatGPT account

Opening ChatGPT

ChatGPT is opening in a new tab.