Simple Recursive approach
Approach\nWe will calculate the sum of all possible prime factors and compare it with the number of which we are calculating for if sum is less we will recursiv
# Approach\nWe will calculate the sum of all possible prime factors and compare it with the number of which we are calculating for if sum is less we will recursively calculate for it or else return it since it breaks condition;\n# Complexity\n- Time complexity:\n- It is recursive in approach\n\n# Code\n```\nclass Solution {\npublic:\n    int smallestValue(int n)\n    {\n        int q=n;\n        int p=0;\n        while(n%2==0)\n        {\n            p=p+2;\n            n=n/2;\n        }\n        for(int i=3;i<=sqrt(n);i=i+2)\n        {\n            while(n%i==0)\n            {\n                p=p+i;\n                n=n/i;\n            }\n        }\n        if (n > 2)\n        {\n            p=p+n;\n        }\n        if(q>p)\n        {\n            q=p;\n            return smallestValue(p);\n        }\n        else\n        {\n            return p;\n        }\n    }\n};\n\nPlease upvote if it helps!!
['Recursion', 'C++']