Compute counts with a basic while loop