Suppose we have numbers from $2$ to $n$ (inclusive). We want to choose numbers such that all of them are coprime and give the maximum sum.
For example, if $n=10$, then we choose $9,8,7,5$ and the sum is $29$. Note that we didn't choose $10,9,7$ since the sum is smaller than the former. I did this by trial and error. Is there an algorithm which gives me the numbers?