use strict; use warnings; for my $left (1 .. 4) { for my $right (0 .. $left -1) { printf "%05b\n", (1 << $left) | (1 << $right); } }