Until One (Reduce Rules)

JavaScript Medium 3 views
Back to Questions

Problem Description

Given n, in one step you can do: if even n=n/2 else n=n-1. Count steps to reach 1. Print steps.

Input Format

One integer n.

Output Format

One integer steps.

Sample Test Case

Input:
7
Output:
5

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next