It's correct. The answer will always be the greatest power of two less than or equal to the upper limit. I came to this conclusion from reviewing what you wrote. The reason is that it's impossible to eliminate any power of 2 from the list until it's the first element in the list.

A little more explanation: The first time you went through, you only removed odd numbers. The second time you went through, you only removed numbers that were divisible by 2 but not 4. Then you removed numbers divisible by 4 but not 8. Etc.