Call a nonempty subset of satisfying the condition a divisor chain.
For a positive integer , let be the number of divisor chains whose largest element is exactly . Every element of such a chain divides .
If we remove , the remaining chain is either empty or a divisor chain whose largest element is some proper divisor of . Conversely, adding to any such chain yields a chain with largest element . Therefore,
The initial represents the singleton chain consisting only of .
Each divisor chain selected from has exactly one largest element , and divides . Hence
Compute in increasing order. Initialize every to . Once is known, add it to for every proper multiple of . Since , all contributions from proper divisors are already known when is processed.
The recurrence implies , so
Iterating over multiples as in the sieve of Eratosthenes gives time complexity and space complexity . Over , the maximum answer is , which fits in signed -bit integers.
Solution written by GPT6