Given a number H which represent the total number of holes. The task is to find the smallest number which has that many numbers of holes.
- 0, 4, 6, 9 has 1 holes each and 8 has 2 holes in it.
- The number should not contain leading zeros.
Input: H = 1
Input: H = 5
Number which has 5 holes in it is 488. i.e (1 + 2 + 2)
- First of all, Check whether the number of holes given is 0 or 1, if 0 then print 1 and if 1 then print 0.
- If number of holes given is more than 1 then divide the number of holes by 2 and store the remainder in ‘rem’ variable. and quotient in ‘quo’ variable.
- Now, if value of rem variable is equal to 1 then first print 4 once and then print 8 quo number of times.
- Else print 8 only quo number of times.
Below is the implementation of the above approach:
- Write a program to calculate pow(x,n)
- Write a program to reverse digits of a number
- Program to find whether a no is power of two
- Write an Efficient Method to Check if a Number is Multiple of 3
- Program to find parity
- Write an Efficient C Program to Reverse Bits of a Number
- Write a program to print all permutations of a given string
- Write a program to add two numbers in base 14
- Minimum number of jumps to reach end
- Find minimum number to be divided to make a number a perfect square
- Find whether a given number is a power of 4 or not
- Print all combinations of points that can compose a given number
- Find Union and Intersection of two unsorted arrays
- Program for Fibonacci numbers
- Check if a number is multiple of 5 without using / and % operators
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.