Make Number Odd
Easy Accuracy: 34.99% Submissions: 100 Points: 2

Given a number N. Print the minimum positive integer by which it should be divided so that the result is an odd number.

Example 1:

Input:
N = 36
Output:
4
Explanation:
36 must be divided by 4 or 12 to make it
odd. We take minimum of 4 and 12 i.e. 4.

Example 2:

Input:
N = 5
Output:
1
Explanation:
5 is already odd.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function makeNumberOdd() which takes an integer N as an input parameter and return the minimum positive integer by which it should be divided so that the result is an odd number.

Expected Time Complexity: O(LogN)
Expected Auxiliary Space: O(1)

Constraints:
1 <= N <= 100000

 

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Make Number Odd

Output Window