```
class Solution {
public:
int minSteps(int n) {
if(n==1) return 0;
int steps = 0;
int i;
while(n%2 == 0){
steps += 2;
n /= 2;
}
for( i=3; i <= sqrt(n); i += 2){
while(n%i == 0){
steps += i;
n /= i;
}
}
return (n != 1)?(steps + n):(steps);
}
};
```