Skip to content

Commit

Permalink
1342
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 22, 2022
1 parent d29e7c5 commit 324e95e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions E_1342_NumberofStepstoReduceaNumbertoZero.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Solution {
public int numberOfSteps (int n) {
if ( n == 0) {
return 0;
}
return 1 + numberOfSteps(n % 2 == 0 ? n / 2 : n - 1);
}
}

0 comments on commit 324e95e

Please sign in to comment.