❄ Easy Java Solution ❄ Beats 100% of Java Users .
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int sumP(int n) {\n        int sum = 0;\n        while (n % 2 == 0) {\n            sum += 2;\n            n >>= 1; \n        }\n        for (int i = 3; i * i <= n; i += 2) {\n            while (n % i == 0) {\n                sum += i;\n                n /= i;\n            }\n        }\n\n        if (n > 1) {\n            sum += n;\n        }\n        return sum;\n    }\n\n    public int smallestValue(int n) {\n        int k = 0;\n        while (true) {\n            k = sumP(n);\n            if (n == k) {\n                return n;\n            }\n            n = k;\n        }\n    }\n}\n\n```
['Java']