Are you working with 20 bit integers? You'll never get it down to a million lines like that...

There's a million lines of
If >4096, subtract 4096

Then a quick lookup case statement for whether the remaining number is even.