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.
- Time required to meet in equilateral triangle
- Double Base Palindrome
- Divide number into two parts divisible by given numbers
- Find all factorial numbers less than or equal to n
- N expressed as sum of 4 prime numbers
- Find the last digit when factorial of A divides factorial of B
- Next higher palindromic number using the same set of digits
- Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- To check a number is palindrome or not without using any extra space
- Check if a number N starts with 1 in b-base
- N'th palindrome of K digits
- Program for factorial of a number
- Program for nth Catalan Number
- Efficient program to print all prime factors of a given number
- Program for Fibonacci numbers