Compute integer powers of 2 using while loop