# Sum of all the prime divisors of a number | Set 2

Sum of all the prime divisors of a number | Set 2 Given a number N, the task is to find the sum of all the prime factors of N. Examples:Input: 10Output: 7Explanation: 2, 5 are prime divisors of 10Input: 20Output: 7Explanation: 2, 5 are prime divisors of 20Approach: This problem can be solved by finding all the prime factors of the number. Follow the steps below to solve this problem:Initialize a variable sum as 0 to store the sum of prime divisors of N.If N is divisible by 2, add 2 to sum and divide N by 2 until it is divisible.Iterate in the range [3, sqrt(N)] using the variable i, with an increment of 2:If N is divisible by i, add i to sum and divide N by i until it is divisible.If N is a prime number greater than 2, add N to sum.After completing the above steps, print the sum as the answer.Below is the implementation of the above approach:C++  #include using namespace std;  int SumOfPrimeDivisors(int n){      int sum = 0;          if (n % 2 == 0) {        sum = sum + 2;    }      while (n % 2 == 0) {        n = n / 2;    }          for (int i = 3; i 2) {        sum = sum + n;    }      return sum;}  int main(){        int n = 10;          cout