The code copy is as follows:
function ten2eight(x){
var s=[];
var r='';
while(x>0){
s.push(x%8);
x=parseInt(x/8);
}
while(s.length>0){
r=r+s.pop();
}
return r;
}
N=(N div 8)*8+(N mod 8) (div is the dividing operation, mod is the balance)
For a non-negative decimal integer input to octal, the calculation process generates octal digits in sequence from low to high, and when output, it should generally be from high to low, which is the opposite of the calculation process.
Note: When taking the divisor, you need to round the parseInt