Created
July 16, 2016 09:56
-
-
Save pmbanka/11831cb2a8a11cd43459dc7c0bd2040e to your computer and use it in GitHub Desktop.
Convert decimal to binary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
let toBin n = | |
let rec toBinImpl n = seq { | |
let div, rem = Math.DivRem (n, 2) | |
yield rem | |
if div <> 0 then yield! toBinImpl div } | |
toBinImpl n |> Seq.rev |> Seq.toArray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment