I am working on a project involving \"Dynamic Programming\" and am struck on this trivial thing, please help.
Suppose I take 4 as an input, I want to display somethi
public void outBinary(int value){
for (int i = 0; i < Math.pow(2, value); i++) {
System.out.println(Integer.toBinaryString(i));
}
}
with leading zeros something like that
for (int i = 0; i < Math.pow(2, value); i++) {
StringBuilder binary = new StringBuilder(Integer.toBinaryString(i));
for(int j = binary.length(); j < value; j++) {
binary.insert( 0, '0' );
}
System.out.println(binary);
}