Find n’th number in a number system with only 3 and 4 Given a number system with only 3 and 4. Find the nth number in the number system. First few numbers in the number system are: 3, 4, 33, 34, 43, 44, 333, 334, 343, 344, 433, 434, 443, 444, 3333, 3334, 3343, 3344, 3433, 3434, 3443, 3444, … We strongly recommend to minimize the browser and try this yourself first. We can generate all numbers with i digits using the numbers with (i-1) digits. The idea is to first add a ‘3’ as prefix in all numbers with (i-1) digit, then add a ‘4’. For example, the numbers with 2 digits are 33, 34, 43 and 44.
Read full article from Find n'th number in a number system with only 3 and 4 - GeeksforGeeks
No comments:
Post a Comment