JAVA | Simplest and Shortest ✅
Please Upvote :D\njava []\nclass Solution {\n    public int smallestValue(int n) {\n        int ori = n, ans = n;\n        int k = 2, sum = 0;\n\n        while 
# Please Upvote :D\n``` java []\nclass Solution {\n    public int smallestValue(int n) {\n        int ori = n, ans = n;\n        int k = 2, sum = 0;\n\n        while (true) {\n            if (n % k == 0) {\n                sum += k;\n                n /= k;\n            }\n            else k++;\n\n            if (n == 1) {\n                if (sum == ori) {\n                    break;\n                }\n                ori = n = sum;\n                sum = 0;\n                k = 2;\n                ans = Math.min(ans, n);\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Java']