This paper presents a two-phase algorithm for computing exact Catalan numbers at an unprecedented scale. The method is demonstrated by computing $C(n)$ for $n = 2,050,572,903$ yielding a result with a targeted $1,234,567,890$ decimal digits. To circumvent the memory limitations associated with evaluating large factorials, the algorithm operates exclusively in the prime-exponent domain. Phase 1 employs a parallel segmented sieve to enumerate primes up to $2n$ and applies Legendre's formula to determine the precise prime factorization of $C(n)$. The primes are grouped by exponent and serialized to disk. Phase 2 reconstructs the final integer using a memory-efficient balanced product tree with chunking. The algorithm runs on a time complexity of $Θ(n(\log n)^2)$ bit-operations and a space complexity of $Θ(n \log n)$ bits. This result represents the largest exact Catalan number computed to date. Performance statistics for a single-machine execution are reported, and verification strategies -- including modular checks and SHA-256 hash validation -- are discussed. The source code and factorization data are provided to ensure reproducibility.
翻译:本文提出了一种两阶段算法,用于以前所未有的规模精确计算卡特兰数。该方法通过计算 $n = 2,050,572,903$ 时的 $C(n)$ 得以验证,所得结果具有目标值 $1,234,567,890$ 位十进制数字。为规避计算大阶乘时伴随的内存限制,该算法完全在素数指数域内运行。第一阶段采用并行分段筛法枚举所有不超过 $2n$ 的素数,并应用勒让德公式确定 $C(n)$ 的精确素数分解。素数按其指数分组并序列化存储至磁盘。第二阶段使用一种具有分块功能的内存高效平衡乘积树来重构最终整数。该算法的时间复杂度为 $Θ(n(\log n)^2)$ 比特操作,空间复杂度为 $Θ(n \log n)$ 比特。此结果代表了迄今为止计算出的最大精确卡特兰数。文中报告了单机执行的性能统计数据,并讨论了验证策略——包括模校验和 SHA-256 哈希验证。提供了源代码和分解数据以确保可复现性。