It tests whether you can write a simple loop with a couple of ifs - not being able to do it is definitely an indicator that you won't be able to complete more advanced programming tasks. And pretty much any other programming task is more advanced.
It doesn't have to be asked during the full technical interview stage.