0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

1342. Number of Steps to Reduce a Number to Zero

Posted at

1342. Number of Steps to Reduce a Number to Zero

特に考慮したことはなし

class Solution:
    def numberOfSteps(self, num: int) -> int:
        divided_num = num
        counter = 0

        while divided_num != 0:
            if(divided_num % 2 == 0):
                divided_num = divided_num / 2
            else:
                divided_num -= 1
            counter += 1
        return counter
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?