How to convert a decimal number to octal? What is the function for this?

    1 answer 1

    in php:

    base_convert($num, 10, 8); 

    or

     decoct ($num); 

    The verification algorithm is as follows:

    1. We divide the decimal number A by 8. We remember the partial Q for the next step, and write the remainder a as the low-order bit of the octal number.

    2. If the quotient q is not equal to 0, we take it as a new dividend and repeat the procedure described in step 1. Each new remainder is written into the digits of the octal number in the direction from the least significant bit to the most significant bit.

    3. The algorithm continues until, as a result of performing steps 1 and 2, we get the quotient Q = 0 and the remainder a is less than 8.