Writing algorithms using the while-statement