Convert Number to Binary

Given a number, return the binary value of the number

Problem Statement

Given a number, return the binary value of the number

Solution

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

def num_to_binary(num):
    if num>=1:
        num_to_binary(num//2)

    if num%2:
        print("1", end="")
    else:
        print("0", end="")

num_to_binary(13)
print()
num_to_binary(15)