Somewhat related, "Gosper's hack" is a fun way to loop through all of the values that have the same number of 1s.