for beginners
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []
/**
 * @param {number} n
 * @return {number}
 */
var smallestValue = function(n) {
    let primeFacsum=(n)=>{
        let sum=0
        while(n%2==0){
            sum+=2
            n=n/2
        }
        for(let i=3;i<=n;i+=2){
            while(n%i==0){
                sum+=i
                n=n/i
            }
        }
        return sum
    }
    while(n>primeFacsum(n)){
        n=primeFacsum(n)
    }
    return n
};
```
['JavaScript']