[C++] Beats 92% || Prime Factorization
Code\n\nclass Solution {\npublic:\n    int primeFactors(int n)\n    {\n        int sum = 0;\n\xA0\xA0\xA0\xA0    int count = 2;\n\xA0\xA0\xA0\xA0    while(n>1)\
# Code\n```\nclass Solution {\npublic:\n    int primeFactors(int n)\n    {\n        int sum = 0;\n\xA0\xA0\xA0\xA0    int count = 2;\n\xA0\xA0\xA0\xA0    while(n>1)\n\xA0\xA0\xA0 \xA0   {\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0    if(n % count == 0){\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0        sum += count;\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0        n/=count;\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0    }\n\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0    else count++;\n\xA0\xA0\xA0\xA0    }\n        \n        return sum;\n    }\n    \n    int smallestValue(int num) {\n        int sum = 0;\n        int prev = 0;\n        \n        map<int,int> visited;\n\xA0       \n        while (num) {\n            prev = num;\n\xA0\xA0\xA0\xA0        num = primeFactors(num);\n            \n            // if current prime factor is visited again then return the previous factor\n            if (visited[num]) {\n                return prev;\n            } else {\n                visited[num] = 1;\n            }\n        }\n        \n\xA0\xA0\xA0\xA0    return 1;\n    }\n};\n```
['C++']