programming-examples/r/Binary to Decimal.r
2019-11-18 14:03:28 +01:00

16 lines
275 B
R

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