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.
- Check if Decimal representation of an Octal number is divisible by 7
- Check if a number is Palindrome
- Check if a number is Palindrome in PL/SQL
- Program to check the number is Palindrome or not
- Bash program to check if the Number is a Palindrome
- Recursive program to check if number is palindrome or not
- To check a number is palindrome or not without using any extra space
- Generate number with given operation and check if it is palindrome
- Check if binary representation of a number is palindrome
- Check if a number with even number of digits is palindrome or not
- Check if actual binary representation of a number is palindrome
- Program to Convert Octal Number to Binary Number
- Check if any anagram of a string is palindrome or not
- Check if a string is palindrome in C using pointers
- Check if it is possible to create a palindrome string from given N