Write a definition of function binary(n) that takes a positive integer n and yields a string that is the base 2 (binary) representation of n. For example, 310 = 112, so binary(3) = "11". Here are some more examples.
  binary(1) = "1"
  binary(4) = "100"
  binary(6) = "110"
  binary(9) = "1001"

Hint.

  1. Have a case for binary(1).

  2. 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
    

  3. 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.

 

  [Language: Cinnameg  Kind: function definition]