mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
Conversions algorithms : remove live code & console.log.
This commit is contained in:
@ -6,11 +6,22 @@ function decimalToOctal (num) {
|
||||
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)
|
||||
return oct
|
||||
}
|
||||
|
||||
decimalToOctal(2)
|
||||
decimalToOctal(8)
|
||||
decimalToOctal(65)
|
||||
decimalToOctal(216)
|
||||
decimalToOctal(512)
|
||||
export { decimalToOctal }
|
||||
|
||||
// > decimalToOctal(2)
|
||||
// 2
|
||||
|
||||
// > decimalToOctal(8)
|
||||
// 10
|
||||
|
||||
// > decimalToOctal(65)
|
||||
// 101
|
||||
|
||||
// > decimalToOctal(216)
|
||||
// 330
|
||||
|
||||
// > decimalToOctal(512)
|
||||
// 1000
|
||||
|
Reference in New Issue
Block a user