Use a for loop rather than while, end should be rounded up