best way to find sum of powers of prime factors of a number

158 Views Asked by At

What is the best way to find the sum of powers of prime factors of a number?

What I did till now is :

for p in primes below limit:
    for v divisible by p
       ans[v] = ans[v] + power of p in v

This is working good when limit is $10^6$

I am interested to know if there is algorithm or recurrence to achieve this in a better way ?