Implementing the Doomsday Rule

For those of you not familiar with this rule: http://rudy.ca/doomsday.html

I'm trying to implement this algorithm into a program, and up until now it has been going fine. I've encountered a problem now though:

I'm trying to find the anchor day of any given century (The program will only accept input from 0000 to 10000)

The anchor days can only be Sundays, Tuesdays, Wednesdays and Fridays, so i'm disregarding the other days.

The algorithm comes up with a number between 1 and 4, 1 is sunday, 2 is tuesday, 3 is wednesday and 4 is obviously friday, or well, atleast that is what it's supposed to do. The loop i'm using starts out at 0, and then increments by 100 and adds 1 to i each time it loops. Then when it reaches the century that was inputted it does i (mod 4).

This is the code i have so far:

Code:

`/* Find the anchor day of the century */`

for(n = 0; n != century; i++)

{

n += 100;

}

i %= 4;

The output i get is wrong, 1900 evaluates to 3 (Which is correct - wednesday), but 1800 is 2 (Which should have been 4) and 2000 becomes 4 (Which in turn should have been 2). It seems like i got it upside down, but how can i fix it then? Has anyone got experience with the doomsday rule, or maybe some of you math experts can come up with a solution for me :)