Re-writing the for-statement using a while-statement and vice versa