Optimizing code for sequence A064604
That's a very naive bruteforce algorithm.  To optimize this sort of calculation you can usually "turn it around" by doing something like: for each possible divisor, computing the number of times it'll feature as a contributor and adding them up.  And if you can get it to work by just iterating over primes, it'll be even better/faster.