Simple java solution
\n\n# Code\n\nclass Solution {\n    public int smallestValue(int n) {\n        int k=n;\n        if(n<=4)\n            return n;\n\t\twhile(true)\n        {\n  
\n\n# Code\n```\nclass Solution {\n    public int smallestValue(int n) {\n        int k=n;\n        if(n<=4)\n            return n;\n\t\twhile(true)\n        {\n            int sum=0;\n            for (int i=2;i<=n/2;i++)\n            {\n                //System.out.println(i);\n                if(prime(i))\n                {\n                    while(n%i==0)\n                    {\n                        sum+=i;\n                        n/=i;\n                        //System.out.println(i);\n                    }\n                }\n\t\t    }\n            if(n==1)\n            {\n                sum-=1;\n            }\n\t\t    sum+=n;\n\t\t    if(n==sum)\n\t\t    {\n                k=sum;\n                break;\n\t\t    }\n\t\t    else\n\t\t    {\n                n=sum;\n                k=sum;\n\t\t    }\n        }\n\t\treturn k;\n    }\n    public boolean prime(int n)\n    {\n        for(int i=2;i<=Math.sqrt(n);i++)\n        {\n            if(n%i==0)\n            {\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```
['Java']