The first number you need in order to work out the doomsday for a year is its anchor day. Anchor days are specific to the century the date falls in.
Each century is linked to a specific anchor day, and since our calendar repeats every 400 years, there are only four anchor days you need to memorize.
Which anchor day does a date in 1985 use?
These weekday numbers simply have to be memorized. Luckily, in most everyday situations, the dates you want to convert to weekdays fall in one or two of these centuries. Knowing that years in 19xx anchor on Wednesday and years in 20xx on Tuesday is enough for almost every practical use.
Those four anchor days are a property of the Gregorian calendar and its 400-year cycle — and that calendar only begins in October 1582, when ten days were struck from the year to bring the date back in step with the sun.
Hand the algorithm an earlier date and it will still answer, but it answers for the Gregorian day carrying those digits — not the day the history books mean. Columbus sighted land on a Friday, October 12, 1492, by the calendar he was keeping; run the same digits through the algorithm and out comes a Wednesday.
Neither is a mistake. They are answers about two different calendars, and before the reform only one of them was in use. So treat 1583 as the floor: from there on, the weekday you work out is the weekday it happened on.