Remove Rightmost Set Bit

Remove Rightmost Set Bit

Medium Python Operators 17 views
Explanation Complexity

Problem Statement

One non-negative integer n is provided (n>0). Remove the rightmost set bit once and output the new number.

Input Format

One integer n.

Output Format

One integer.

Example

12
8

Constraints

1

Input / Output Format

Input Format
One integer n.
Output Format
One integer.
Constraints
1

Examples

Input:
12
Output:
8

Example Solution (Public)

Python
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
sys.stdout.write(str(n & (n-1)))

Official Solution Code

import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
sys.stdout.write(str(n & (n-1)))
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.