Easy C++ Code
Code\n\nclass Solution {\npublic:\n   bool isprime(int n){\n    if (n <= 1)return false;\n    for (int i = 2; i < n; i++)\n        if (n % i == 0)return false;\
# Code\n```\nclass Solution {\npublic:\n   bool isprime(int n){\n    if (n <= 1)return false;\n    for (int i = 2; i < n; i++)\n        if (n % i == 0)return false;\n    return true;\n}\n void primeFactors(int n,vector<int>&v){\n    while (n % 2 == 0){\n        v.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        {\n            v.push_back(i);\n            n = n/i;\n        }\n    }\n    if (n > 2)\n        v.push_back(n);\n}\n    int smallestValue(int n) {\n        if(n==0||n==1||n==4)return n;\n        int sum;\n        while(!isprime(n)){\n            sum=0;\n            vector<int>v;\n            primeFactors(n,v);\n            for(int i=0;i<v.size();i++)sum+=v[i];\n            n=sum;\n        }\n        return sum;\n    }\n};\n```
['C++']