Your algorithm will indeed provide the correct answer. Since you're only asked to find the number of elements and not enumerate them, you're really looking for the size of your set tail. To explain your algorithm, it suffices to convince someone that the algorithm adds a new number, $i$ to the set if (1) $2\le i\le 2004$, (2) $i$ is even, (3) $i$ is divisible by 8 or by 11 (or both). Your algorithm obviously does exactly that, and that proof of correctness suffices.
There's computationally simpler way to do this problem, by the way. Ask the question "How many numbers in $\{2, 4, \dots, 2004\}$ are divisible by 8?" Those will be $\{8, 16, 24, \dots, 2000\}$ and there will be $\lfloor 2004/8\rfloor$ of them, where $\lfloor x\rfloor$ represents the greatest integer less than or equal to $x$.
In a similar way, there will be $\lfloor 2004/22\rfloor$ even numbers in your range divisible by 11. Leading to the conclusion that there will be $ \left\lfloor\frac{2004}{8}\right\rfloor+\left\lfloor\frac{2004}{22}\right\rfloor= 250+91=341 $ numbers in your range divisible by either 8 or 11. However, we've counted the numbers divisible by both 8 and 11 twice, once in each sum, so we have to subtract the numbers divisible by 88, giving us $ \left\lfloor\frac{2004}{8}\right\rfloor+\left\lfloor\frac{2004}{22}\right\rfloor-\left\lfloor\frac{2004}{88}\right\rfloor= 250+91-22=319 $ as expected. This is known as the principle of inclusion/exclusion and is often very useful.