Very Simple Recursion
\n\n/*\nHere we use the theorem to optimize the runtime, that is prime no can be always in the form of 6k+1 or 6k-1, except 2 & 3\nSo we only itereate on 2, 3, 
```\n\n/*\nHere we use the theorem to optimize the runtime, that is prime no can be always in the form of 6k+1 or 6k-1, except 2 & 3\nSo we only itereate on 2, 3, 6k-1 & 6k + 1\nWe have return a separate function that just keep on evluating the sum of all factor and return total sum.\n*/\nclass Solution {\npublic:\n    int find(int n, int i, int j, bool b){ \n        if(n <= i) return n;\n        if(n%i == 0) {\n            return i + find(n/i, i, j, b);\n        }\n        int t = 0;\n        if(i == 2) t = 3;\n        else{\n            if(b) { t = j*6+1; j++; }\n            else t = j*6-1;\n            b = !b;\n        }\n        return find(n, t, j, b );\n    }\n    int smallestValue(int n) {\n        while(1){\n            int t = find(n, 2, 1, false);\n            if(t == n) return n;\n            n = t;\n        }\n        return 0;\n    }\n};\n```
['C++']