Smallest Value After Replacing With Sum Of Prime Factors
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# 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```python3 []\nclass Solution:\n    def smallestValue(self, n: int) -> int:\n        while 1:\n            t, s, i = n, 0, 2\n            while i <= n // i:\n                while n % i == 0:\n                    n //= i\n                    s += i\n                i += 1\n            if n > 1:\n                s += n\n            if s == t:\n                return t\n            n = s\n```
['Python3']