Here's a Python program that converts a positive integer to its binary representation:
The Code
def decimal_to_binary(num):
binary = ""
while num > 0:
remainder = num % 2
binary = str(remainder) + binary
num //= 2
return binary if binary else "0"
# Taking input from the user
number = int(input("Enter a positive integer: "))
binary_representation = decimal_to_binary(number)
print(f"The binary representation of {number} is: {binary_representation}")
This program defines a function decimal_to_binary that converts a positive integer into its binary representation by iteratively dividing the number by 2 and appending the remainders (0s or 1s) to form the binary string