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 email@example.com. 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a number with even number of digits is palindrome or not
- To check a number is palindrome or not without using any extra space
- Recursive program to check if number is palindrome or not
- Program to check the number is Palindrome or not
- Check if number is palindrome or not in base B
- Sentence Palindrome (Palindrome after removing spaces, dots, .. etc)
- Count all palindrome which is square of a palindrome
- Check linked list with a loop is palindrome or not
- Check if a doubly linked list of characters is palindrome or not
- Check if any anagram of a string is palindrome or not
- Program to check if an array is palindrome or not using Recursion
- Check if there exists any sub-sequence in a string which is not palindrome
- Check if all elements of the array are palindrome or not
- Program to check if an Array is Palindrome or not
- Program to check if an Array is Palindrome or not using STL in C++
- Queries to check if substring[L...R] is palindrome or not
- Check if sum of any subarray is Palindrome or not
- Check if Inorder traversal of a Binary Tree is palindrome or not
- Check given string is oddly palindrome or not | Set 2
- Check if row-major order path of Matrix is palindrome or not