Merge pull request #11 from ms10398/master

Added Implementation of Decimal to Octal
This commit is contained in:
Anup Kumar Panwar
2017-08-20 13:05:53 +05:30
committed by GitHub

View File

@ -0,0 +1,15 @@
function decimalToOctal(num) {
var oct = 0,c=0;
while (num > 0) {
var r=num%8;
oct=oct+(r*Math.pow(10,c++));
num =Math.floor(num/ 8); // basically /= 8 without remainder if any
}
console.log("The decimal in octal is " + oct);
}
decimalToOctal(2);
decimalToOctal(8);
decimalToOctal(65);
decimalToOctal(216);
decimalToOctal(512);