In [1]:
function dec_to_bin(dec)
    ret = 0
    pow = 1
    while dec > 0
        val = dec % 2
        dec = Int(trunc(dec / 2))
        ret += val*pow
        pow *= 10
    end
    return ret
end


Out[1]:
dec_to_bin (generic function with 1 method)

In [2]:
println(dec_to_bin(41))


101001

In [ ]: