Clean Code || C++ || O(1) Space
```\nclass Solution {\npublic:\n     \n    int smallestValue(int n) {\n        int x = n;\n        int ans = n;\n        \n        while(true) {\n            in
```\nclass Solution {\npublic:\n     \n    int smallestValue(int n) {\n        int x = n;\n        int ans = n;\n        \n        while(true) {\n            int check = x; // Storing x in another variable as x will be lost in each iteration\n            \n            \n            int num = x; // Condition variable to be used in for loop\n            \n            x = 0; // Reusing variable to store sum of factors\n            \n            \n            // Sieve Algorithm to get prime factorisation\n            \n            for(int i = 2; i <= num; i++) {\n                while(num % i == 0) {\n                    num = num / i;\n                    x += i; // Adding factor to x;\n                }\n            }\n            \n            ans = min(x, ans);\n            \n            if(x == check) break; // Base condition to break out i.e Sum of factors = Product of factors\n        }\n        \n        return ans;\n    }\n};
['C']