You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
Binary to Decimal
|
|
# Program to convert decimal
|
|
# number into binary number
|
|
# using recursive function
|
|
|
|
convert_to_binary <- function(n) {
|
|
|
|
if(n > 1) {
|
|
convert_to_binary(as.integer(n/2))
|
|
}
|
|
cat(n %% 2)
|
|
}
|
|
Output
|
|
|
|
> convert_to_binary(52)
|
|
110100 |