Easy cpp
\nclass Solution {\npublic:\n    int smallestValue(int n) {\n        int primes = primeFactors(n);\n        if(primes ==  n) {\n            return n;\n        }
```\nclass Solution {\npublic:\n    int smallestValue(int n) {\n        int primes = primeFactors(n);\n        if(primes ==  n) {\n            return n;\n        }\n        return smallestValue(primes);\n    }\n    int primeFactors(int n) {\n       int result = 0;\n           while (n % 2 == 0)\n           {\n               result += 2;\n               n = n/2;\n           }\n           for (int i = 3; i <= sqrt(n); i = i + 2)\n           {\n               while (n % i == 0)\n               {\n                   result += i;\n                   n = n/i;\n               }\n           }\n        if(n > 2) {\n           result += n;\n        }\n     return result;\n}\n \n};\n```
['Math']