Beginner friendly Java Solution
Code\n\nclass Solution {\n    public int smallestValue(int n) {\n        if(n == 0 || n == 4)  return 4;\n        return factors(n);\n    }\n    private int fac
# Code\n```\nclass Solution {\n    public int smallestValue(int n) {\n        if(n == 0 || n == 4)  return 4;\n        return factors(n);\n    }\n    private int factors(int n){\n        int i, sum = 0;\n        for(i=2; i<=n; i++){\n            while(n%i == 0){\n                sum += i;\n                n /= i;\n            }\n        }\n        return isPrime(sum) ? sum : factors(sum);     \n    }\n    private boolean isPrime(int sum){\n        for(int i=2; i<sum/2; i++){\n            if(sum % i == 0)    return false;\n        }\n        return true;\n    }\n}\n```
['Java']