C++ Solution || 100% beat time || Bruteforce
Intuition\n Describe your first thoughts on how to solve this problem. \nSimple Bruteforce implementation.\n\n# Approach\n Describe your approach to solving the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimple Bruteforce implementation.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nApplying bruteforce approach. Continuosly finding the sum of the prime factors and checking if the sum is equal to the same value of N or not.\n\nIf N is prime no. then it will take $$sqrt(N)$$ time.\nOtherwise it wiil take $$sqrt(N)$$ + logarithmic time.\n\n# Complexity\n- Time complexity: sqrt(n) + logarithmic time complexity\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int findsumoffactors(int n){\n        int sum=0;\n        int x=n;\n        for(int i=2;i*i<=x;i++){\n            while(n%i==0){\n                sum+=i;\n                n/=i;\n            }\n        }\n        if(n>1) sum+=n;\n        return sum;\n    }\n\n    int smallestValue(int n) {\n        int x;\n        while(true){\n            x=n;\n            n=findsumoffactors(n);\n            if(x==n) break;\n        }\n        return x;\n    }\n};\n```
['C++']