Consider a number is base 4. There are 4 single digit numbers, 16 two digit numbers (including leading zeroes), 64 three digit numbers (including leading zeroes). In general, there are 4^n n-digit numbers (including leading zeroes). So, let’s say the input is 4. Then for each number from 1 to 4^n - 1 = 4^4 - 1 = 255, convert to a number in base 4. For example, let’s try 117:

117/4 = 29, with a remainder of 1

29/4 = 7, with a remainder of 1

7/4 = 1, with a remainder of 3

1/4 = 0, with a remainder of 1

So, in base 4 the base 10 numeral 117 is written as 1311. To check, confirm that 1*64 + 3*16 + 1*4 + 1*1 = 117. Now, just convert those digits to letters, with 0=A, 1=B, 2=C, 3=D. In this case, we get 1311 = BDBB. This process will return only digits 0, 1, 2, and 3, and will return every possible combination except for all 0s, because we started our counting at 1 instead of 0. This means you’ll get every combination except for all As returned.