Project Euler #211: Divisor Square Sum
As always, before tackling the Project Euler problems, do your math homework. Few hints:


Do not brute force. \$\sigma_2(n)\$ is multiplicative. That allows it to be computed in a much more efficient way.
Do not throw away your work. \$\sigma_2(n)\$ does not depend on \$k\$. Tabulate it once toward the maximal possible \$N\$, or extend it as \$N\$ grows.


Besides that, the constraints say \$1 &lt; N &lt; 6\cdot 10^6, 0 &lt; K &lt; 10^6\$. uint_16 is surely insufficient.