C++ || Simple Prime Factorisation || EAsy to Understand
\n# Code\n\nclass Solution {\npublic:\n    int smallestValue(int n) {\n        while(n){\n            int sum = 0;\n            int prev = n;\n            for(i
\n# Code\n```\nclass Solution {\npublic:\n    int smallestValue(int n) {\n        while(n){\n            int sum = 0;\n            int prev = n;\n            for(int i=2;i<=n;){\n                if(n%i ==0){\n                    sum+=i;\n                    n/=i;\n                }\n                else{\n                    i++;\n                }\n            }\n            if(prev == sum )return sum;\n            if(sum == 0)return n;\n            n=sum;\n        }\n        return 0;\n    }\n};\n```
['C++']