easiest solution || c++ || easy to understand
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    vector<int> primeFactors(int n){\n        vector<int> ans;\n        while (n % 2 == 0){\n            ans.push_back(2);\n            n = n/2;\n        }\n        for (int i = 3; i <= sqrt(n); i = i + 2){\n            while (n % i == 0){\n                ans.push_back(i);\n                n = n/i;\n            }\n        }\n        if (n > 2) ans.push_back(n);\n        return ans;\n    }\n    int smallestValue(int n) {\n        if(n<6) return n;\n        vector<int> temp;\n        temp = primeFactors(n);\n        n = accumulate(temp.begin(),temp.end(),0);\n        while(n>0 && temp.size()>1){\n            temp.clear();\n            temp=primeFactors(n);\n            n=accumulate(temp.begin(),temp.end(),0);\n        }\n        return n;\n    }\n};\n```
['C++']