Easy C++ solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPrime(int n){\n        if(n<2) return false;\n        for(int i=2 ; i<=sqrt(n) ; i++){\n            if(n%i == 0){\n                return false;\n            }\n        }\n        return true;\n    }\n    int smallestValue(int n) {\n        if(isPrime(n)) return n;\n        int mini = INT_MAX;\n        int m = n;\n        int sum;\n        do\n        { \n            sum = 0;\n            while(n%2==0){\n                sum += 2;\n                n=n/2;\n            }\n            for(int i=3 ; i<=sqrt(n) ; i=i+2){\n                while(n%i == 0){\n                    sum += i;\n                    n = n/i;\n                }\n            }\n            if(n>2){\n                sum += n;\n            }\n            mini = min(mini , sum);\n            n = sum;\n        }while(isPrime(sum) == false && sum < m);\n        \n        return mini;\n    }\n};\n```
['C++']