Decimal to octal conversion with minimum use of arithmetic operators
Given a decimal number n without floating-point. The problem is to convert the decimal number to octal number with minimum use of arithmetic operators.
Input : n = 10 Output : 12 12 is octal equivalent of decimal 10. Input : n = 151 Output : 227
Approach: Following are the steps:
- Perform decimal to binary conversion without using arithmetic operators of the given number n. Refer this post. Let this number be bin.
- Convert the binary number bin to octal. Refer this post.
Time Complexity: O(n), where n is the length of the binary string.