python3 Solution
\n\nclass Solution:\n    def smallestValue(self, n: int) -> int:\n        while True:\n            c=2\n            t=0\n            b=n\n\n            while c*
\n```\nclass Solution:\n    def smallestValue(self, n: int) -> int:\n        while True:\n            c=2\n            t=0\n            b=n\n\n            while c*c<=n:\n                while n%c==0:\n                    n//=c\n                    t+=c\n\n                c+=1\n\n            if t==0:\n                return n\n\n            if t>=b:\n                return b\n\n            if n>1:\n                t+=n\n\n            n=t                    \n```
['Python3']