binary(1) = "1" binary(4) = "100" binary(6) = "110" binary(9) = "1001"
Hint.
Have a case for binary(1).
If n is even then the binary representation of n ends on 0. Get binary(n `div` 2) and add a 0 to the end. For example,
binary(6) = binary(3) ++ "0" = 110
If n is odd then the binary representation of n ends on 1. Get binary(n `div` 2) and add a 1 to the end.