Skip to content

Commit 315e110

Browse files
committed
1342
1 parent 19e39ff commit 315e110

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

1342.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int numberOfSteps (int n) {
4+
int count=0;
5+
while(n!=0)
6+
{
7+
if(n%2==0)
8+
n=n/2;
9+
else
10+
{
11+
n=n-1;
12+
}
13+
count++;
14+
}
15+
return count;
16+
}
17+
};

0 commit comments

Comments
 (0)