i was just playing around with the idea of not using if statement and decided to do a program which outputs the number of factors a number has
"10 has four factors 1,2,5,10" and did two programs
The latter is faster because it uses 5 less arithmetic operations than the former per loop.
When computing the number of factors of 'n', the second uses n arithmetic operations, while the first uses 6n operations. It doesn't have anything to do with the if statement.
EDIT:
I went and tested it out by looking at the disassembly, the first generates this:
You can see that the second uses way fewer operations to complete.
Note: Amount of assembly generated isn't always a good measure for how long a program takes to execute; but generally when designing algorithms you want to use the absolute minimum amount of clock cycles to complete the task.