Easy Java Solution
\n# Code\n\nclass Solution {\n    public int smallestValue(int n) {\n        int sum = 0;\n        int ans=Integer.MAX_VALUE;\n        HashSet<Integer> hs=new H
\n# Code\n```\nclass Solution {\n    public int smallestValue(int n) {\n        int sum = 0;\n        int ans=Integer.MAX_VALUE;\n        HashSet<Integer> hs=new HashSet<>();\n        while(!hs.contains(n)){\n            hs.add(n);\n            // check from 2 to n whenever n is the factor of c add it to the sum\n            int c = 2;\n            while (n > 1) {\n                if (n % c == 0) {\n                    sum+=c;\n                    n /= c;\n                }\n                else\n                    c++;\n            }\n            ans=Math.min(sum,ans);\n            n=sum;\n            sum=0;\n        }\n        return ans;\n    }\n    \n}\n```
['Java']