Advertisement
STANAANDREY

to bin nr

Jan 19th, 2023
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. def decimal_to_binary(decimal):
  2.     if decimal == 0:
  3.         return 0
  4.     elif decimal == 1:
  5.         return 1
  6.     else:
  7.         remainder = decimal % 2
  8.         return int(str(decimal_to_binary(decimal // 2)) + str(remainder))
  9.  
  10.  
  11. print(decimal_to_binary(4099))
  12.  
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement