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.
- Largest Even and Odd N-digit numbers in Octal Number System
- Check if a number has an odd count of odd divisors and even count of even divisors
- Count of integers in a range which have even number of odd digits and odd number of even digits
- 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 N digit Octal number which is a Perfect square
- Count of Octal numbers upto N digits
- Largest and Smallest N-digit Octal Numbers
- Program to Convert Octal to Hexadecimal
- Check whether a given number is even or odd
- Program to check if a number is Positive, Negative, Odd, Even, Zero
- Check whether given floating point number is even or odd
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Check if product of digits of a number at even and odd places is equal
- Check if a N base number is Even or Odd
- Check if the number is even or odd whose digits and base (radix) is given
- Check if a Number is Odd or Even using Bitwise Operators
- Check if a HexaDecimal number is Even or Odd
- Check whether count of odd and even factors of a number are equal
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.