Write a recursive method called countBinary that accepts an integer n as a parameter and that prints all binary numbers that have exactly n digits in ascending order, each on its own line. All n digits should be shown for all numbers, including leading zeros if necessary. Assume that n is nonnegative. If n is 0, a blank line should be produced.
Call | Output |
countBinary(1); | 0 |
| 1 |
countBinary(2); | 00 |
| 01 |
| 10 |
| 11 |
countBinary(3); | 000 |
| 001 |
| 010 |
| 011 |
| 100 |
| 101 |
| 110 |
| 111 |
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.