Steward
分享是一種喜悅、更是一種幸福
程式語言 - LeetCode - C++ - 650. 2 Keys Keyboard
題目:

解答:
class Solution {
public:
int minSteps(int n) {
int ans = 0;
for (int i = 2; i * i <= n; ++i) {
while (n % i == 0) {
ans += i;
n /= i;
}
}
if (n > 1) {
ans += n;
}
return ans;
}
};