g | x | w | all
Bytes Lang Time Link
005Japt h250101T121247ZShaggy
008J250101T030650Zsouth
009Uiua241231T215346Znyxbird
101Java 8171004T121506ZKevin Cr
033Factor210507T083053Zchunes
061Haskell171004T110640ZLaikoni
004Ohm v2171004T132350ZCinaski
063Javascript ES6171004T175140ZEndenite
063Ruby171004T164722ZSnack
084Python 2171004T141459Zovs
030Retina171004T110155ZMartin E
124PowerShell171004T132904ZAdmBorkB
053R + pracma171004T131409ZGiuseppe
035Mathematica171004T104440Zuser2027
003Pyth171004T113348ZErik the
00305AB1E171004T110423Zscottine
006MATL171004T104403ZLuis Men
005Jelly171004T110231Zthe defa
004Husk171004T110932ZLaikoni
006Jelly171004T110840ZSherlock
007Actually171004T105303Zuser4594

Japt -h, 5 bytes

Æ=k x

Try it

Æ=k x     :Implicit input of integer U
Æ         :Map the range [0,U)
 =        :  Reassign to U
  k       :    Prime factors
    x     :    Sum
          :Implicit output of last element

Japt, 7 bytes

Works for input 1.

@=k x}g

Try it

J, 8 bytes

+/@q:^:_

Attempt This Online!

+/@q:^:_
     ^:_   NB. to fixed point
   q:      NB. prime factors
  @        NB. then
+/         NB. sum

Uiua, 9 bytes

⍥(/+°/×)∞

Try it!

⍥(/+°/×)∞
⍥(     )∞  # repeat until fixed point:
     °/×    #   factorize
   /+       #   sum

Java 8, 175 144 142 141 139 101 bytes

n->{for(int i=n;i-->0;)n=f(n,2);return n;};int f(int n,int d){return n>1?n%d<1?f(n/d,2)+d:f(n,d+1):0;}

-38 bytes porting @ovs' Python answer, so make sure to upvote him as well!

Try it online.

n->{                 // Method with integer as both parameter and return-type
  for(int i=n;i-->0;)//  Loop the input `n` amount of times:
    n=f(n,2);        //   Change `n` that many times by calling the recursive method
                     //   with n,2 as parameters
  return n;}         //  Then return the potentially modified `n` as result

int f(int n,int d){  // Separated method with 2 integer parameters & integer return
                     // (`d` is 2 when we initially call this recursive-method)
  return n>1?        //  If input `n` is larger than 1:
          n%d<1?     //   If `n` is divisible by `d`:
           f(n/d     //    Divide `n` by `d`
             ,2)     //    Do a recursive call with n/d,2 as parameters
                +d   //    And add `d` to its result
          :          //   Else:
           f(n,d+1)  //    Do a recursive-call with the next `d` by using n,d+1 as
                     //    parameters
         :           //  Else:
          0;}        //   Simply return 0

Original 175 144 142 141 139 bytes answer:

n->{for(int i,t=n,x;;n=t){for(i=2;i<t;)t=t%i++<1?0:t;if(t>1|n<5)return n;for(t=0,i=1;i++<n;)for(;n%i<1;t+=x)for(n/=x=i;x>9;x/=10)t+=x%10;}}

-1 byte thanks to @Nevay
-2 bytes thanks to @ceilingcat

Explanation:

Try it online.

n->{                 // Method with integer as both parameter and return-type
  for(int i,         //  Index-integer `i`
          t=n,       //  Temp integer `t`, starting at the input `n`
          x;         //  Temp integer `x`
      ;              //  Loop indefinitely:
      n=t){          //    After every iteration, replace `n` with the value `t`
    for(i=2;i<t;)    //   Inner loop `i` in the range [2,t):
      t=t%i++<1?     //    If `t` is divisible by `i`:
         0           //     Set `t` to 0
        :            //    Else:
         t;          //     Leave `t` the same
    if(t>1           //   If `t` is not 0 or 1 (it means it's a prime),
       |n<5)         //   or if `n` is below 5 (for edge-cases n=1 and n=4)
      return n;      //    Return `n` as result
    for(t=0,         //   Reset `t` to 0
        i=1;         //   Reset `i` to 1
        i++<n;)      //   Inner loop `i` in the range (2,n]:
      for(;n%i<1;    //    Inner loop as long as `n` is divisible by `i`:
          t+=x)      //      After every iteration: Increase `t` by `x`
        for(n/=x=i;  //     Reset `x` to `i`
                     //     And divide `n` by `i`
            x>9;     //     Inner loop as long as `x` contains more than 1 digit:
            x/=10)   //       After every iteration, remove the trailing digit of `x`
          t+=x%10;}} //      Increase `t` with the trailing digit of `x`

Factor, 33 bytes

[ [ factors Σ ] to-fixed-point ]

Try it online!

Haskell, 61 bytes

import Data.Numbers.Primes
until=<<((==)=<<)$sum.primeFactors

Try it online!

Explanation

until=<<((==)=<<) takes a function f and applies it to input x until a fix point is reached, that is f x equals x. primeFactors returns the list of prime factors of a number, sum yields the sum of a list of numbers.

But wait, why does until=<<((==)=<<) the job and looks so weird?

If we assume f=sum.primeFactors, a more natural definition would be until(\x->f x==x)f, because until takes a predicate (a function which returns a boolean), a function which has the same input and return type (e.g. Int -> Int) and value of this type, and then applies the function to the value until the predicate is fulfilled.

until(\x->f x==x)f is the same as until(\x->(==)(f x)x)f, and as it holds that g (h x) x is the same as (g=<<h)x, we get until(\x->((==)=<<f)x)f. After Eta conversion, this becomes until((==)=<<f)f. But if we now treat (==)=<< as a function which is applied to f, we can see that until(((==)=<<)f)f is again of the form g (h x) x, with g=until, h=((==)=<<) and x=f, so it can be rewritten to (until=<<((==)=<<))f. Using the $ operator to get rid of the outer parentheses and substituting f with sum.primeFactors yields the solution from above.

Ohm v2, 4 bytes

·ΘoΣ

Try it online!

Explanation:

·Θ    evaluate the block until the result returned has already been seen
   Σ  sum
  o   the full prime factorization

Javascript (ES6), 63 bytes

f=n=>(q=(p=(m,x)=>m<x?0:m%x?p(m,x+1):x+p(m/x,x))(n,2))^n?f(q):q
<input id=i type=number min=0 value=0 oninput="o.innerText=f(i.value)">
<p id=o></p>

Ungolfed:

f=n=>(                  // Recursive function `f`
    p=(m,x=2)=>(        //   Recursive function `p`, used to sum prime factors
        m<x?            //     If m (the number to be factored) is less than x (the current
            0           //     iteration), return 0
        :m%x?           //     Else if m doesn't divide x
            p(m,x+1)    //     run the next iteration
        :               //     Else (if m divides x)
            x+p(m/x,x)  //     Divide m by x and repeat the current iteration
    ),
    q=p(n),             //   Set q to the sum of the prime factors of n
    q^n?                //   If q != n then
        f(q)            //     repeat f with q
    :                   //   else
        q               //     return q
)

Ruby, 63 bytes

->n{n.times{n=n.prime_division.map{|x|x.reduce:*}.sum};n}

Try it online!

Uses the -rprime flag for +6 bytes to make use of Prime#prime_division.

prime_division returns pairs of [prime, exponent] (for example, for 24 we have the factors [2, 2, 2, 3] so it gives [[2, 3], [3, 1]]) so in each step we just multiply the members of those pairs together and sum the results.

Python 2, 84 bytes

f=lambda n,d=2:n>1and(n%d and f(n,d+1)or d+f(n/d))
i=input()
exec'i=f(i);'*i
print i

Try it online!

Retina, 30 bytes

{+`(\1|\b11+?\B)+$
$1;$#1$*
;

Input and output in unary.

Try it online! (Performs decimal/unary conversion for convenience.)

Explanation

{+`(\1|\b11+?\B)+$
$1;$#1$*

The { instructs Retina to run the entire program in a loop until a full pass fails to modify the string, i.e. until a fixed point is reached. Consequently, the program itself computes one step of summing the prime factors of the current value.

This stage itself computes the prime factorisation of the input. The + is similar to { but loops only this stage until it stops changing the string. The regex tries to match the final run of 1s by repeatedly matching the same substring (i.e. the factor). The way this is done is a bit convoluted due to the forward reference \1. On the first iteration, group 1 hasn't captured anything yet, so \1 fails unconditionally. Instead, we have to match \b11+?\B which is the smallest possible substring that starts at the beginning of the run, contains at least two 1s and doesn't cover the entire run. Subsequent iterations will not be able to use this alternative again, due to the \b. So on all further iterations, we're matching \1, i.e. the same substring over and over again. This process has to hit the end of the string exactly ($) to make sure we've captured and actual divisor. The benefit of using this somewhat tricky approach is that group 1 will have been used exactly n/d times, i.e. what remains after dividing out the divisor d.

We replace this match with d ($1), a separating ; and n/d ($#1$*, which inserts $#1 copies of 1, where $#1 is the number of captures made by group 1).

This process stops once the final run in the string is itself a prime, because then the regex no longer matches.

;

All we need to do to sum the primes is to remove all the separators.

PowerShell, 124 bytes

function f($a){for($i=2;$a-gt1){if(!($a%$i)){$i;$a/=$i}else{$i++}}}
for($x=$args[0];$l-ne$x){$l=$x;$x=(f($x))-join'+'|iex}$x

Try it online!

PowerShell doesn't have any prime factorization built-ins, so this uses code from my answer on Prime Factors Buddies (the top line) to perform the factorization calculations.

The second line is the meat of this program. We take input from $args into $x, then for loop until $l is -notequal to $x. (The first iteration, $l is $null and $x is an integer, so we'll loop at least once).

Inside the loop, we set our $l = $x to determine if we've hit the end of the loop or not. Then we get the factors of $x with f($x), -join those together with + and |iex them (short for Invoke-Expression and similar to eval). That's stored back into $x. Thus, we've hit the "end" where the prime factorization summed together is back to itself. Then, we simply place $x on the pipeline and output is implicit.

R + pracma, 53 bytes

function(n){for(i in 1:n)n=sum(pracma::factors(n))
n}

Try it online! (r-fiddle)

R doesn't have a prime factors builtin, but numerous packages (pracma, numbers, etc.) do, so I picked a conveniently short one.

Mathematica, 35 bytes

#//.x_:>Tr[1##&@@@FactorInteger@x]&

Try it online!

(Mathics does not support Tr. I have to implement it manually)

Pyth, 3 bytes

usP

Try it here.

Explanation:

usPGQ The trailing GQ is implicit
  PG  Get prime factors
 s    Sum
u   Q Repeat until returned value no longer unique starting with the input

05AB1E, 3 bytes

FÒO

Try it online!

Explanations:

FÒO   
F    Loops <input> times + 1
 Ò   List of prime factors w/ duplicates
  O  Total sum of the list
     -- implicit output

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected.

t:"Yfs

Try it online!

Explanation

t       % Take input (implicit). Duplicate
:"      % Do the following that many times
  Yf    %   Array of prime factors
  s     %   Sum of array
        % End (implicit). Display (implicit)

Jelly, 5 bytes

ÆfS$¡

Explanations:

Æf    list of prime factors
  S   sum
   $¡ repeat n times

Try it online!

Husk, 4 bytes

ω(Σp

Try it online!

Explanation:

ω(   -- apply the following function until the result no longer changes (fixpoint)
  Σ  -- sum
   p -- the list of primefactors

Jelly, 6 bytes

This answer uses one of Jelly's many prime factorization builtins, and the quick for repeat until the results are no longer unique.

ÆfSµÐL

Try it online!

Actually, 7 bytes

⌠w♂πΣ⌡Y

Try it online!

Explanation:

⌠w♂πΣ⌡Y
⌠    ⌡Y  do this until output stops changing (fixed-point combinator)
 w         factor into [prime, exponent] pairs
  ♂π       product of each pair
    Σ      sum of products