@protein.graph the origin i = 1 which is 001 in binary code, and suppose num = 5

then i << 1 on every loop,it will be like 0010,0100,1000,which is 2,4,8,then i -1 = 7, which is 0111 in binary,and the ^ calculation means get opposite,when 111^101,you will get 010,which is 2