C++ || MATHS
Code\n\nclass Solution {\npublic:\n    int smallestValue(int n) {\n        int x ,k,i;\n        while(n){\n            x = 0;\n            k = n;\n            f
# Code\n```\nclass Solution {\npublic:\n    int smallestValue(int n) {\n        int x ,k,i;\n        while(n){\n            x = 0;\n            k = n;\n            for(i = 2; i <= sqrt(n); i++){\n                while(n%i == 0){\n                    x += i;\n                    n /= i;\n                }\n            }\n            if(n>1)x += n;\n            if(k == x)return x;\n            n = x;\n        }\n        return x;\n    }\n};\n```
['Math', 'Number Theory', 'C++']