From db063ad4a92b6a01426ea262d9086f311c1dd8a8 Mon Sep 17 00:00:00 2001 From: Saksham Garg <55405810+sakshusakshusakshu@users.noreply.github.com> Date: Fri, 12 Jun 2020 11:24:17 +0530 Subject: [PATCH] Create BinaryNumHR.py --- BinaryNumHR.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 BinaryNumHR.py diff --git a/BinaryNumHR.py b/BinaryNumHR.py new file mode 100644 index 0000000..badd3b6 --- /dev/null +++ b/BinaryNumHR.py @@ -0,0 +1,48 @@ +""" +Task +Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation. + +Input Format + +A single integer, . + +Constraints + +Output Format + +Print a single base- integer denoting the maximum number of consecutive 's in the binary representation of . + +Sample Input 1 + +5 +Sample Output 1 + +1 +Sample Input 2 + +13 +Sample Output 2 + +2 +Explanation + +Sample Case 1: +The binary representation of is , so the maximum number of consecutive 's is . + +Sample Case 2: +The binary representation of is , so the maximum number of consecutive 's is . +""" +# SOLUTION +#!/bin/python3 + +import math +import os +import random +import re +import sys + + + +if __name__ == '__main__': + n = int(input()) +print(max(len(length) for length in bin(n)[2:].split('0')))