The Divide-or-Multiply Sequence: Exact Structure and an Optimal Algorithm
Let a(1)=1 and a(m+1)=a(m)/m if m divides a(m), and a(m+1)=m*a(m) otherwise (OEIS A008336). We prove the product identity a(n) = (n-1)! / product_{m<n, m divides a(m)} m^2, establish an exact recursion on the prime exponents that decides the divisibility condition m divides a(m), and show that the exponent of a prime p > sqrt(n) behaves as a ballot-type walk with fixed parity. The exponent recursion yields the exact prime factorization of a(n) in O(n log log n) arithmetic operations using O(n) memory, completely outperforming the traditional big-integer iteration which requires Omega(n^2 / log n) word operations. Since a(n) >= product_{n/2<p<n} p, the number a(n) has at least (1/(2 ln 2) + o(1)) * n bits. Therefore, any algorithm that outputs a(n) in binary requires Omega(n / log n) steps. This proves that the proposed exponent framework is optimal up to a minor factor of O(log n log log n), and no algorithm can evaluate a(n) in o(n / log n) steps. All theoretical claims are rigorously proved. In C, the compact implementation computes the complete factorization of the monster term a(10^9) in 55.9 seconds using 2 GB of memory. On smaller scales (n=10^5), the exponent framework runs 17 times faster than big-integer iteration in Python and approximately 500 times faster in C.
Authors
- Mark Kim (ORCID: https://orcid.org/0000-0001-7601-831X)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-11-09
- DOI
- https://doi.org/10.5281/zenodo.24085264
- Primary Topic
- Analytic Number Theory Research
- Type
- preprint