diff --git a/Program to convert binary to decimal b/Program to convert binary to decimal new file mode 100644 index 0000000000..bdf0082b13 --- /dev/null +++ b/Program to convert binary to decimal @@ -0,0 +1,14 @@ +function DecimalToBinary(num) { + + if (num >= 1) { + DecimalToBinary(Math.floor(num / 2)); + } + process.stdout.write((num % 2).toString()); +} + +// Driver code +const dec_val = 5; // Decimal value + +// Calling function +DecimalToBinary(dec_val); +console.log(); //output:5