C++ || Easy way to find smallest value
IntuitionWe need to find the smallest value, and this smallest value will always be a prime number.ApproachIn a "while" loop, we try to find the divisors of our
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We need to find the smallest value, and this smallest value will always be a prime number.
# Approach
<!-- Describe your approach to solving the problem. -->
In a "while" loop, we try to find the divisors of our number and add them to primeSum. If primeSum is equal to our number, it means we have found the smallest number, and we return it. Otherwise, we continue searching for the smallest number.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```cpp []
class Solution {
public:
    int smallestValue(int n) 
    {
        int primeSum=0;
        int tmpN=n;

        while(tmpN!=1)
        {
            for(int i =2 ; i <=tmpN;++i)
            {
                if(tmpN%i==0)
                {
                    tmpN=tmpN/i;
                    primeSum+=i;
                    break;
                }
            }
        }   
        
        //if primeSum == n that means its prime number so its the smallest value
        return primeSum==n ? n : smallestValue(primeSum);
    }
};
```
['C++']