First thing that I was told in College: All programs have bugs.
You just do the best that you can to find them, and hope that those you miss aren’t catastrophic.
I started when speed was important.
I would have found the first even number, calculated the number of even numbers in the range, and then added 2 to the starting number in the loop.
It would eliminate the IF statement and the loop would be half as long.
My first app out of college ran for 18 years without a single update. It solved 40 equations with 90 unknowns.
Good article for beginners.