There are many ways to do that, for example you can get the prime factors looping through all the numbers from 2 to the square root of 'n' then if that number divides n you add it to another variable,
another way to do it is using the sieve of erastotenes and then you search in the sieve from 2 to the square root of 'n' and add it to a variable 'sum' if the number divides 'n' and it's prime
a link from wikipedia
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes[
^]