Of course you can. Please write (binary digit - 1) instead of "31" in line 2. For example, you'll get 4 digit binary, you should write "FOR I=3..." in line 2.
Coding's an art and everyone's slightly different. I like Hanzo's way of thinking. Here's mine. The trick is to keep dividing by 2 until it's gonna be less than 1, then stop and print the remainders. This way no leading zeroes will appear.