aboutsummaryrefslogtreecommitdiffstats
path: root/1342/main.cpp
blob: b8609d969e38c9c0cc1e8f709ab3a8e7ccbc2973 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "header.hpp"

class Solution {
public:
  static int numberOfSteps(int num) {
    auto dummy = num;
    int counter = 0;
    while (dummy != 0) {
      if (dummy % 2 == 0) {
        dummy = dummy >> 1;
      } else {
        dummy--;
      }
      counter++;
    }
    return counter;
  }
};

int main(int argc, char **argv) { std::cout << Solution::numberOfSteps(123); }