Quicker method: Sieve of Eratosthenes

A simple method for converting a for-loop into a while loop:

for(init; condition; increment)
{
// loop code
}