C++ || Beats 80% || Recursion || Prime Factor
\n# Code\n\nclass Solution {\npublic:\n    /* intution : Recursion\n        base case\n         if(isPrime(n))\n          return n;\n         else\n          n 
\n# Code\n```\nclass Solution {\npublic:\n    /* intution : Recursion\n        base case\n         if(isPrime(n))\n          return n;\n         else\n          n tak k prime factor nekal le\n          eg 15 - 2,3,5,7,11,13 -> yaha se calculate newN\n    */\n    bool isPrime(int n){\n     for(int i = 2;i * i <= n;i++){\n            if(n % i == 0)return false;\n        }\n     return true;\n}  \n    int solve(int n)\n    {\n        // base case\n    if(isPrime(n)){\n            return n;\n    }\n        vector<int> temp;\n        int d=2;\n        int x=n;\n        while(x>1)\n        {\n            if(x%d==0)\n            {\n                temp.push_back(d);\n                x=x/d;\n            }\n            else\n             d++;\n        }\n\n        int newN=0;\n        for(int i=0;i<temp.size();i++)\n            newN+=temp[i];\n        \n        if(newN == n)\n         return n;\n        return solve(newN);\n    }\n    int smallestValue(int n) {\n        return solve(n);\n    }\n};\n```
['Recursion', 'C++']