SIMPLE PYTHON SOLUTION
Intuition\nMy intuition is that if I encounter any prime number in the process then that is the minimum of till now will be the answer or if we come across same
# Intuition\nMy intuition is that if I encounter any prime number in the process then that is the minimum of till now will be the answer or if we come across same number twice then we will return the minimum value.\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```\nfrom math import sqrt\n\nclass Solution:\n    def primeFactors(self,n):\n        x=0\n        while n % 2 == 0:\n            x+=2\n            n = n // 2\n\n        for i in range(3,int(math.sqrt(n))+1,2):\n            while n % i== 0:\n                x+=i\n                n = n // i\n        if n > 2:\n            x+=n\n        return x\n\n    def isPrime(self,n):\n        prime_flag = 0\n        if(n > 1):\n            for i in range(2, int(sqrt(n)) + 1):\n                if (n % i == 0):\n                    prime_flag = 1\n                    break\n            if (prime_flag == 0):\n                return True\n            else:\n                return False\n        else:\n            return True\n\n    def smallestValue(self, n: int) -> int:\n        lst=[0]*100001\n        mn=n\n        \n        while True:\n            if lst[n]==1:\n                return mn\n            if self.isPrime(n):\n                return min(n,mn)\n            lst[n]=1\n            n=self.primeFactors(n)\n            mn=min(mn,n)\n\n            \n```
['Python3']