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 number in [2, 3, .. n] which is co-prime with numbers in [2, 3, .. m]
- Program to Convert Octal Number to Binary Number
- 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
- 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 palindrome which is product of two n-digit numbers
- Sum and product of k smallest and k largest composite numbers in the array
- Largest of two distinct numbers without using any conditional statements or operators
- Sum and product of k smallest and k largest prime numbers in the array
- Number of times the largest perfect square number can be subtracted from N
- Find the largest good number in the divisors of given number N
- Largest even number that can be formed by any number of swaps
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.