Created
January 29, 2022 09:49
-
-
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.
This file contains hidden or 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
| 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