Brute force, but easy and self-explainatory solution
\n\n# Code\njava []\nclass Solution {\n    public int smallestValue(int n) {\n        int k=n;\n        if(n<=4) return n;\n        while(true){\n            in
\n\n# Code\n```java []\nclass Solution {\n    public int smallestValue(int n) {\n        int k=n;\n        if(n<=4) return n;\n        while(true){\n            int sum=0;\n            for(int i=2;i<=n/2;i++){\n                if(prime(i)){\n                    while(n%i==0){\n                        sum+=i;\n                        n/=i;\n                    }\n                }\n            }\n\n\n            //EDGE CASES \n            if(n==1) {\n                sum-=1;\n            }\n            sum+=n;\n            if(n==sum){\n                k=sum;\n                break;\n            } else {\n                n=sum;\n                k=sum;\n            }\n        }\n        return k;\n    }\n    private boolean prime(int n){\n        for(int i=2;i<=n/2;i++){\n            if(n%i==0){\n                return false;\n            }\n        }\n        return true;\n    }\n}\n\n```
['Java']