adding second exponential approach that uses a while loop