Question: I am not able to meet all the conditions of prime factors of a number so that I find the correct sum. 

```
    int sumPrime(number){

         int counter;
         int sum=0;
         for(counter=2;counter<=(number/2);counter++){
           if(number%counter==0){
              sum=counter;
              counter++;
              sum+=counter;

              }
           return sum;  

          }
    }

```

Answer: 
I think the code is self explanatory. It works for `number >= 2`.

```
int sumPrime(int number){
     int factor = 2;
     int sum=0;

    while(1 != number){ //Repeat the loop till number becomes 1.
       if(number%factor==0){ //Check if factor divides the number.
          number /= factor; //If yes, update the number.
          sum+=factor; //Add factor to sum.
          printf("Factor [%d]\n", factor);
          continue;
        }
        factor++; //If the current number is not a factor, check the next number.
    }
    printf("Sum [%d]\n", sum);
    return sum;
}

```

Output for 12:

```
Factor [2]                                                                                                                                      
Factor [2]                                                                                                                                      
Factor [3]                                                                                                                                      
Sum [7] 

```
```js
let n = 22;
let sum = 0;

function sumOfPrimeFactors(n) {
  // Write your code here
  if(n === 2){
    return true;
  }
  if(n < 2 || isNaN(n) || (n%2===0)){
    return false;
  }
  for(let i = 3; i < n; i++){
    if(n%i === 0){
      return false;
    }
  }
  return true;
}

for(let i = 0; i <= n; i++){
  if(sumOfPrimeFactors(i) === true){
    if(n % i === 0){
      sum += i;
    }
  }
}
console.log(`The sum of the prime factors in 91 is: ${sum}`)

```