spider68

2 key keaboard (min step for AAAA....)

Mar 27th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int minSteps(int n) {
  4.         int s=0,x=2;
  5.         int ans=0;
  6.         while(n>1)
  7.         {
  8.             if(n%x==0){ans+=x;
  9.                        n/=x;}
  10.             else x++;
  11.         }
  12.         return ans;
  13.     }
  14.    
  15. };
Add Comment
Please, Sign In to add comment