← back to unit
Medium
# puzzle gauntlet medium
The Binary Cake
Computers count with only 0s and 1s. The recipe: divide your number by 2, keep the remainder, repeat — then read the remainders BACKWARDS. Wait… collecting things and reading them backwards… you own a machine for that! 🎂
You get n (at least 1). Print its binary form.
Example:
Input: n = 13
Output: 1101
Dividing by 2 repeatedly (13→6→3→1→0) gives remainders 1, 0, 1, 1; reading them backwards spells 1101.
💡 need a hint?
pg-binary-cake.py🔒 given lines are locked — write your code in between
loading...