Simple to understand
# Intuition\nbrute force\n# Approach\ncreate a function to check if a number is a prime, and a function to sum the prime factors\ndeal with exception of n=4\nrun a while loop as long as the number doesnt become prime, the sum of prime factors of a prime number is the number itself;\n\n# Code\n```cpp []\nclass Solution \n{\npublic:\nbool isPrime(int n) {\n    if (n <= 1)\n        return false;\n    for (int i = 2; i <= std::sqrt(n); ++i) {\n        if (n % i == 0)\n            return false;\n    }\n    return true;\n}\n    int sumofprime(int n)\n    {\n        int sum=0;\n        int i=2;\n        while(n!=1)\n        {\n            if(n%i==0)\n            {\n                sum+=i;\n                n/=i;\n            }\n            else\n                i++;\n        }\n        return sum;\n    }\n    int smallestValue(int n) \n    {\n        if(n==4)\n            return 4;\n        while(!isPrime(n))\n        {\n            n=sumofprime(n);\n        }\n        return n;\n    }\n};\n```
['C++']