Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
Created January 29, 2022 09:49
Show Gist options
  • Select an option

  • Save CodeMaster7000/610b6fd345452e69393dcd80ff0bf2ae to your computer and use it in GitHub Desktop.

Select an option

Save CodeMaster7000/610b6fd345452e69393dcd80ff0bf2ae to your computer and use it in GitHub Desktop.
A program in R to convert a decimal number into binary using recursion.
convert_to_binary <- function(n) {
if(n > 1) {
convert_to_binary(as.integer(n/2))
}
cat(n %% 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment