Given an integer N, the task is to find the largest even and odd N-digit numbers in Octal Number System.
Input: N = 4
Even : 7776
Odd : 7777
Input: N = 2
Even : 76
Odd : 77
Approach: To get the largest number, the digits of the number have to be maximum possible. Since in the octal number system, the maximum digit is ‘7’. So, generate ‘7’ (N – 1) times and then append ‘6’ for even and ‘7’ for odd in the end.
Below is the implementation of the above approach:
Even : 7776 Odd : 7777
Time Complexity: O(n)
- Largest and Smallest N-digit Octal Numbers
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Largest N digit Octal number which is a Perfect square
- Count of Octal numbers upto N digits
- Largest number in [2, 3, .. n] which is co-prime with numbers in [2, 3, .. m]
- Largest N digit number divisible by given three numbers
- Largest number by which given 3 numbers should be divided such that they leaves same remainder
- Program to Convert Octal Number to Binary Number
- Check if an Octal number is Even or Odd
- Check if number is palindrome or not in Octal
- Check if Decimal representation of an Octal number is divisible by 7
- Largest Even and Odd N-digit numbers
- Smallest and Largest sum of two n-digit numbers
- Largest Even and Odd N-digit numbers of base B
- Largest palindrome which is product of two N-digit numbers : Set 2
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.