Python3 | Finding prime factors | Intuitive | Easy to understand
\n# Code\n\nclass Solution:\n    def prime_factors(self, n):\n        i = 2\n        factors = []\n        while i * i <= n:\n            if n % i:\n           
\n# Code\n```\nclass Solution:\n    def prime_factors(self, n):\n        i = 2\n        factors = []\n        while i * i <= n:\n            if n % i:\n                i += 1\n            else:\n                n //= i\n                factors.append(i)\n        if n > 1:\n            factors.append(n)\n        return factors\n    \n    def smallestValue(self, n: int) -> int:\n        num = n\n        seen = set()\n        while num > 0:\n            factors = self.prime_factors(num)\n            if len(factors) == 1:\n                return factors[0]\n            num = sum(factors)\n            if num in seen:\n                break\n            seen.add(num)\n        return num\n            \n        \n        \n```
['Math', 'Python3']