def dec2bin(ndec):
    """
    Convert a decimal number into a string representing
    the same value in binary format.
    """
    if ndec < 1:
        return "0"
    binary = []
    while ndec != 0:
        binary.append(ndec%2)
        ndec = ndec/2
    strbin = ""
    binary.reverse()
    for i in binary:
        strbin = strbin+str(i)
    return strbin