In the other two cases `$results` is calculated through `$last = $first+$results;`, which it could also be here.
That makes it a common calculation that should be made below the `if, else if, else` - as a common code-path.