Given an Octal number N, check whether it is even or odd.
Input: N = 7234 Output: Even Input: N = 333333333 Output: Odd
- Convert the number from Octal base to Decimal base.
- Then check if the number is even or odd, which can be easily checked by dividing by 2.
Time Complexity: O(N)
Efficient approach: Since Octal numbers contain digits from 0 to 7, therefore we can simply check if the last digit is either ‘0’, ‘2’, ‘4’ or ‘6’ . If it is, then the given Octal number will be Even, else Odd.
Below is the implementation of the above approach.
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 number is palindrome or not in Octal
- Check if Decimal representation of an Octal number is divisible by 7
- Program to Convert Octal Number to Binary Number
- Largest Even and Odd N-digit numbers in Octal Number System
- Largest N digit Octal number which is a Perfect square
- Program to Convert Octal to Hexadecimal
- Count of Octal numbers upto N digits
- Largest and Smallest N-digit Octal Numbers
- Check if a large number is divisible by a number which is a power of 2
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- Check if the number is a Prime power number
- Program to check whether the given number is Buzz Number or not
- Check if a number with even number of digits is palindrome or not
- Check if a number has same number of set and unset bits
- Program to check whether a number is Proth number or not
- Check if a given number is factorial of any number
- Check if a number is an Achilles number or not
- Check if a number is a Mystery Number
- Check if a number is a Trojan Number
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.