What I am trying to do is print all the possibilities of a binary number n digits long. In other words, with a 4 digit number:
0001
0010
0100
1000
..etc
To be honest, I have no idea of where to even start with this (other than I figure I’d need to use a loop, and probably an array) so any pointers in the right direction would be appreciated.
Maybe you could use a recursive algorithm:
You would execute this like this:
That would give you all possible binary numbers with 4 digits.
Hope this helped!