Given a number which may be in octal or in decimal. If the number is not octal then convert it into octal then check if it is palindrome or not. If it is palindrome then print 1 otherwise print 0. If the number is already in octal then check if the number is palindrome or not.
Input :n = 111 Output : Yes Explanation: all digits of 111 are in 0-7 so it is a octal number. Read 111 the result is same backward and forward so it is a palindrome number. Input : 68 Output : No Explanation: 68 is not a octal number because it's all digits are not in 0-7. So first we need to convert it into octal (68)base10(Decimal) = (104)base8(octal) 104 is not palindrome. Input : 97 Output : Yes Explanation: 97 is not a octal number because it's all digits are not in 0-7 so first we need to convert it into decimal to octal (97)base10(Decimal) = (141)base8(octal) 141 is palindrome so output = 1.
Octal Number : The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7.
How to Convert Decimal Number to Octal Number :
This article is contributed by R_Raj. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Time required to meet in equilateral triangle
- Find all factorial numbers less than or equal to n
- Program for Fibonacci numbers
- To check a number is palindrome or not without using any extra space
- Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Number of Permutations such that no Three Terms forms Increasing Subsequence
- Check if the first and last digit of the smallest number forms a prime
- Print all substring of a number without any conversion
- Complement of a number with any base b
- Check if Decimal representation of an Octal number is divisible by 7