Advertisement
Nenogzar

Untitled

Mar 5th, 2024
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. n = int(input())
  2. b = int(input())
  3. binary_list = []
  4.  
  5. while n > 0:
  6.     remainder = n % 2
  7.     binary_list.insert(0, remainder)
  8.     n = n // 2
  9.  
  10.  
  11. binary_str = ''.join(map(str, binary_list))
  12. count_b_digit = binary_str.count(str(b))
  13.  
  14. print(binary_str) # Hex
  15. print(count_b_digit)  # count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement