ArticleslgStudy

computer science

Doomsday rule

Doomsday rule is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Doomsday rule rather than just read about it. In short: The Doomsday rule, Doomsday algorithm or Doomsday method is an algorithm of determination of the day of the week for a given date. It provides a perpetual calendar because the Gregorian calendar moves in cycles of 400 years.

Doomsday rule — main illustration
Doomsday rule — illustration

Key takeaways

  • Doomsday rule belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Doomsday rule to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Doomsday rule from memory before moving on to harder problems.

Reference excerpt

The Doomsday rule, Doomsday algorithm or Doomsday method is an algorithm of determination of the day of the week for a given date. It provides a perpetual calendar because the Gregorian calendar moves in cycles of 400 years. The algorithm for mental calculation was devised by John Conway in 1973, drawing inspiration from Lewis Carroll's perpetual calendar algorithm. It takes advantage of each year having a certain day of the week upon which certain easy-to-remember dates, called the doomsdays, fall; for example, the last day of February, April 4 (4/4), June 6 (6/6), August 8 (8/8), October 10 (10/10), and December 12 (12/12) all occur on the same day of the week in the year. Applying the Doomsday algorithm involves three steps: determination of the anchor day for the century, calculation of the anchor day for the year from the one for the century, and selection of the closest date out of those that always fall on the doomsday, e.g., 4/4 and 6/6, and count of the number of days (modulo 7) between that date and the date in question to arrive at the day of the week. The technique applies to both the Gregorian calendar and the Julian calendar, although their doomsdays are usually different days of the week. The algorithm is simple enough that it can be computed mentally. Conway could usually give the correct answer in under two seconds. To improve his speed, he practiced his calendrical calculations on his computer, which was programmed to quiz him with random dates every time he logged on.

Doomsdays for contemporary years Doomsday for the current year in the Gregorian calendar (2026) is Saturday. Simple methods for finding the doomsday of a year exist.

Finding the day of the week from a year's doomsday One can find the day of the week of a given calendar date by using a nearby doomsday as a reference point. To help with this, the following is a list of easy-to-remember dates for each month that always land on the doomsday. The last day of February is always a doomsday. For January, January 3 is a doomsday during common years and January 4 a doomsday during leap years, which can be remembered as "the 3rd during 3 years in 4, and the 4th in the 4th year". For March, one can remember either Pi Day or "March 0", the latter referring to the day before March 1, i.e. the last day of February. For the months April through December, the even numbered months are covered by the double dates 4/4, 6/6, 8/8, 10/10, and 12/12, all of which fall on the doomsday. The odd numbered months can be remembered with the mnemonic "I work from 9 to 5 at the 7–11", i.e., 9/5, 7/11, and also 5/9 and 11/7, are all doomsdays (this is true for both the day/month and month/day conventions). John Conway wrote that: "Summary: 'Last' in Jan and Feb, otherwise nth in even months, (n ± 4) in odd ones". He clarified that: "The sign is + for long odd months (31 days), and − for short ones (30 days)". Several well-known dates, such as Independence Day in United States, Boxing Day, Halloween and Valentine's Day in common years, also fall on doomsdays every year.

Since the doomsday for a particular year is directly related to weekdays of dates in the period from March through February of the next year, common years and leap years have to be distinguished for January and February of the same year.

Example To find which day of the week Christmas Day of 2027 is, proceed as follows: in the year 2027, doomsday is on Sunday. Since December 12 is a doomsday, December 25, being thirteen days afterwards (two weeks less a day), will fall on a Saturday. Christmas Day is always the day of the week before doomsday. In addition, July 4 (U.S. Independence Day) is always on the same day of the week as a doomsday, as are Halloween (October 31), Pi Day (March 14), and December 26 (Boxing Day).

Mnemonic weekday names Since this algorithm involves treating days of the week like numbers modulo 7, John Conway suggested thinking of the days of the week as "Noneday" or "Sansday" (for Sunday), "Oneday", "Twosday", "Treblesday", "Foursday", "Fiveday", and "Six-a-day" to recall the number-weekday relation without needing to count them out in one's head.

There are some languages, such as Slavic languages, Chinese, Estonian, Greek, Portuguese and Hebrew, that base some of the names of the week days in their positional order. The Slavic, Chinese, and Estonian agree with the table above; the other languages mentioned count from Sunday as day one.

Finding a year's doomsday First take the anchor day for the century. For the purposes of the doomsday rule, a century starts with '00 and ends with '99. The following table shows the anchor day of centuries 1600–1699, 1700–1799, 1800–1899, 1900–1999, 2000–2099, 2100–2199 and 2200–2299.

For the Gregorian calendar:

Mathematical formula 5 × (c mod 4) mod 7 + Tuesday = anchor. Algorithmic Let r = c mod 4 if r = 0 then anchor = Tuesday if r = 1 then anchor = Sunday if r = 2 then anchor = Friday if r = 3 then anchor = Wednesday. For the Julian calendar:

6c mod 7 + Sunday = anchor. Note: c=⌊year100⌋. Next, find the year's anchor day. To accomplish that according to Conway:

Divide the year's last two digits (call this y) by 12 and let a be the floor of the quotient. Let b be the remainder of the same quotient. Divide that remainder by 4 and let c be the floor of the quotient. Let d be the sum of the three numbers (d = a + b + c). (It is again possible here to divide by seven and take the remainder. This number is equivalent, as it must be, to y plus the floor of y divided by four.) Count forward the specified number of days (d or the remainder of ⁠d/7⁠) from the anchor day to get the year's one. (⌊y12⌋+ymod12+⌊ymod124⌋)mod7+anchor=Doomsday For the twentieth-century year 1966, for example:

(⌊6612⌋+66mod12+⌊66mod124⌋)mod7+Wednesday=(5+6+1)mod7+Wednesday =Monday As described in bullet 4, above, this is equivalent to:

(66+⌊664⌋)mod7+Wednesday=(66+16)mod7+Wednesday =Monday So doomsday in 1966 fell on Monday. Similarly, doomsday in 2005 is on a Monday:

(⌊512⌋+5mod12+⌊5mod124⌋)mod7+Tuesday=Monday

Why it works

The doomsday's anchor day calculation is effectively calculating the number of days between any given date in the base year and the same date in the current year, then taking the remainder modulo 7. When both dates come after the leap day (if any), the difference is just 365y + ⁠y/4⁠ (rounded down). But 365 equals 52 × 7 + 1, so after taking the remainder we get just

… excerpt ends here. Continue reading the full article.

Illustrations

Doomsday rule: John Conway, inventor of the Doomsday algorithm
John Conway, inventor of the Doomsday algorithm
Doomsday rule: Doomsday rule
Doomsday rule
Doomsday rule: A flowchart showing the Odd+11 method to calculate the anchor day
A flowchart showing the Odd+11 method to calculate the anchor day

Worked examples

Example 1 — a first encounter with Doomsday rule

Start with the simplest possible case. Write down what Doomsday rule claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Doomsday rule before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Doomsday rule ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Doomsday rule

In research
Doomsday rule appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Doomsday rule in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Doomsday rule is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1973 introductions, Calendar algorithms, Gregorian calendar, so understanding it makes those chapters shorter.
In everyday life
Look for Doomsday rule outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Doomsday rule” →

How to study Doomsday rule in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Doomsday rule means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Doomsday rule out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Doomsday rule in simple terms?

The Doomsday rule, Doomsday algorithm or Doomsday method is an algorithm of determination of the day of the week for a given date. It provides a perpetual calendar because the Gregorian calendar moves in cycles of 400 years.

Why does Doomsday rule matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Doomsday rule?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Doomsday rule.

Tags

  • 1973 introductions
  • Calendar algorithms
  • Gregorian calendar
  • John Horton Conway
  • Julian calendar

Keep exploring