C++ || EASY TO UNDERSTAND || 💯
\nclass Solution {\npublic:\n    bool checkPrime(int n){\n        if(n<=1)\n            return false;\n        if(n==2 || n==3)\n            return true;\n     
```\nclass Solution {\npublic:\n    bool checkPrime(int n){\n        if(n<=1)\n            return false;\n        if(n==2 || n==3)\n            return true;\n        if(n%2==0 || n%3==0)\n            return false;\n        for(int i=5;i*i<=n;i+=6){\n            if(n%i==0 || n%(i+2)==0)\n                return false;\n        }\n        return true;\n    }\n    int smallestValue(int n) {\n        if(n==4){\n            return 4;\n        }\n        while(checkPrime(n)==false){\n            int sum=0;\n            while(n%2==0){\n                sum+=2;\n                n/=2;\n            }\n            for(int i=3;i<=sqrt(n);i++){\n                while(n%i==0){\n                    sum+=i;\n                    n/=i;\n                }\n            }\n            if(checkPrime(n))\n                sum+=n;\n            // cout<<sum<<endl;\n            n=sum;\n        }\n        return n;\n    }\n};\n```
[]