In Python2.7 I would like to generate finite sequences for a given integer by repeating the sum of prime factors (sopfr) function over the result(s) until it reaches a prime. The following code for sopfr(n) comes from OEIS A001414.
from sympy import factorint
def sopfr(n):
return sum(p*e for p, e in factorint(n).items())
>>>sopfr(888)
46
>>>
I'd like to alter this code so that it will give this result
>>>sopfrs(888)
46 25 10 7
>>>
Where 46 = sopfr(888), 25 = sopfr(46)... and so on, until this terminates at a prime, in this case 7. I've read some on and experimented with while
and for
loops without luck. Experiments that, I'm sure would be good for a laugh. Forgive the novice nature of this question, any help would be appreciated.