Calculate an integer sequence derived from prime factors Create a function, expression, or program which does the following:


Take the prime factors of any number and sum them. For example, the prime factors of 28 are 2 2 7, summed to 11.
Multiply the result by the number of prime factors for the given number. E.g, 28 has 3 prime factors which sum to 11. 11 * 3 is 33.
Repeat the process recursively, storing the resulting list (which starts with the original number), until you reach a number that is already included in the list. Halt without adding that final number, so that the list contains no duplicates. The progression for 28 is 28 33, because 33 results in 28 again.
Count the elements in the resulting list. In the case of 28, the answer is 2.


Here are the results for 0&lt;n&lt;=10, so you can check your algorithm.

2 1 1 10 1 11 1 9 5 10

(As balpha pointed out, the answer for higley(1) is 2, from the list 1 0. I originally had 1, due to a bug in my original algorithm written in J.)

Since I'm a conceited SOB and haven't found this on OEIS, let's call this the "Higley Sequence," at least for the duration of this round of code golf. As an added bonus, find the first two n having the lowest higley(n) where n is not prime and n&gt;1. (I think there are only two, but I can't prove it.)

This is standard code golf, so as usual the fewest keystrokes win, but I ask that you please upvote clever answers in other languages, even if they are verbose.
J, 47 45

#@((~.@,[:(+/@{:*+/@:*/)2 p:{:)^:_)`2:@.(=&amp;1)


It's possible this would be much shorter without using ^:_, but my brain is sufficiently fried already.

Edit: (47->45) Double coupon day.

Usage:

   higley =: #@((~.@,(+/@{:*+/@:*/)@(2&amp;p:)@{:)^:_)`2:@.(=&amp;1)
   higley 1
2
   higley"0 (1 + i. 10)
2 1 1 10 1 11 1 9 5 10