simple maths || easy to understand
Code\n\nclass Solution {\npublic:\n    int smallestValue(int n) \n    {\n         while(true)\n         {\n             int sum = getsum(n);\n\n             if(
# Code\n```\nclass Solution {\npublic:\n    int smallestValue(int n) \n    {\n         while(true)\n         {\n             int sum = getsum(n);\n\n             if(sum == n)\n             return n;\n\n             n= sum;\n         }    \n         return -1;\n    }\n    int getsum(int n)\n    {\n        int sum = 0;\n        for(int i=2;i*i<=n;i++)\n        {\n            while((n%i) == 0)\n            {\n                sum = sum + i;\n                n = n /i;\n            }\n        }\n        if(n > 1) sum = sum + n;\n        \n        return sum;\n    }\n};\n```
['Math', 'Number Theory', 'C++']