Simple Solution
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)$$ -->0(nlogn)

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

# Code
```cpp []
class Solution {
public:
    bool isprime(int n){
        if(n==1) return false;
        for(int i=2;i<=sqrt(n);i++){
            if(n%i==0) return false;
        }
        return true;
    }
    int smallestValue(int n) {
        if(isprime(n)) return n;
        int sum = 0;
        for(int i=1;i<sqrt(n);i++){
            if(n%i==0 && isprime(i)){
                int m=n;
                while(m%i==0){
                    sum+=i;
                    m/=i;
                }
            }
        }
        for(int i=sqrt(n);i>=1;i--){
            if(n%i==0 && isprime(n/i)){
                int m=n;
                while(m%(n/i)==0){
                    sum+=(n/i);
                    m/=(n/i);
                }
            }
        }
        if(sum==n) return n;
        return smallestValue(sum);
    }
};
```
['C++']