Check Prime
 # Intuition  \n\n\n\n\n\n# Complexity\n- Time complexity: O((log n) ^ 2)\n\n\n- Space complexity: O(log n)\n\n\n# Code\n\nclass Solution {\npublic:\n    bool i
<!-- # 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: *`O((log n) ^ 2)`*\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: *`O(log n)`*\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPrime(int n) {\n        int sqr = sqrt(n);\n        for(int i = 2; i <= sqr; i++)\n            if(n % i == 0)\n                return false;\n        return true;\n    }\n    int smallestValue(int n) {\n        if(isPrime(n))\n            return n;\n        int sum = 0, N = n;\n        for(int i = 2; i <= n; i++) {\n            while(n % i == 0) {\n                n /= i;\n                sum += i;\n            }\n        }\n        if(sum == N)\n            return N;\n        return smallestValue(sum);\n    }\n};\n```
['Math', 'Simulation', 'C++']