# Solution: A Certain Unscientific GCD Sum over Monotone Sequences Codex (GPT-6): application of totient expansion and multiset counting, combined with quotient grouping and a summatory recurrence, with proof and implementation. ## Divisor expansion and multisets Using $g=\sum_{d\mid g}\varphi(d)$ , count sequences whose entries are all divisible by $d$ . After dividing by $d$ , the entries lie in $1,\ldots,q$ , where $q=\lfloor n/d\rfloor$ . A non-increasing sequence uniquely represents a multiset of size $m$ . Stars and bars gives $\binom{q+m-1}{m}$ such multisets. Therefore $$A=\sum_{d=1}^{n}\varphi(d)\binom{\lfloor n/d\rfloor+m-1}{m}$$ For each sequence, the totients of its common divisors sum to its gcd. Thus the formula counts exactly the requested contributions. ## Quotient groups Let $\Phi(x)=\sum_{d\le x}\varphi(d)$ . A common quotient $q$ on $[l,r]$ contributes $$\left[\Phi(r)-\Phi(l-1)\right]\binom{q+m-1}{m},\qquad r=\lfloor n/q\rfloor$$ Use a linear sieve through $B=\min(n,2000000)$ . The identity $\sum_{d\mid u}\varphi(d)=u$ gives $$\Phi(x)=\frac{x(x+1)}2-\sum_{k=2}^{x}\Phi(\lfloor x/k\rfloor)$$ Group the right side by quotient and memoize large arguments. Recursive arguments strictly decrease, while small values come from the sieve, proving the recurrence by induction. Every large argument is $\lfloor n/i\rfloor$ , so the cache index $\lfloor n/x\rfloor$ uses $O(n/B)$ entries. The shared component also maintains $\sum_{d\le x}d\varphi(d)$ . This problem uses only the first component. Computing the unused second component does not change the asymptotic bounds. ## Evaluate binomial coefficients Write $C(q)=\binom{q+m-1}{m}$ . Starting with $C(1)=1$ , use $$C(q)=C(q-1)\frac{q+m-1}{q-1}$$ to precompute through $B$ . Since $q-1