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.
- Decimal to binary conversion without using arithmetic operators
- Program for Decimal to Octal Conversion
- Program for Octal to Decimal Conversion
- Check if Decimal representation of an Octal number is divisible by 7
- Program for Binary To Decimal Conversion
- Program for Decimal to Binary Conversion
- Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
- Convert a binary number to octal
- Program to Convert Hexadecimal to Octal
- Program to Convert Octal Number to Binary Number
- Prefix to Infix Conversion
- Postfix to Prefix Conversion
- Type Conversion in Python
- Prefix to Postfix Conversion
- Program for Hexadecimal to Decimal
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Rajput-Ji