-
Help With Recursion
Hi there,
Im trying to write a method that takes in an int, and counts all the binary numbers up to that length, and prints them one by one. For example, 3 would give:
001
010
011
100
101
110
111
And have come up with something really messy with a whole lot of while loops that doesnt quite work.
I know there must be a simpler way to do it recursively but i cant quite wrap my head around how. Can anyone help?
Thanks a lot
-
Let's see your code. I'm particularly interested in seeing the printing function for outputting binary numbers where from we can then begin to think about making it recursive.
Please post the whole code and be sure to use surrounding [ code] tags.
Oh, and welcome to the Java Forums!