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 an integer division operation, mod is a remainder)
For an input non-negative decimal integer to be converted into octal, the calculation process is to generate the octal digits sequentially from low to high. , and when outputting, generally speaking, it should be from high to low, which is the opposite of the calculation process.
Note: When taking the divisor, you need to round parseInt