John Conway’s mental factoring method and friends

There are tricks for determining whether a number is divisible by various primes, but many of these tricks have to be applied one at a time. You can make a procedure for testing divisibility by any prime p that is easier than having to carry out long division, but these rules are of little use if every one of them is different.

Say I make a rule for testing whether a number is divisible by 59. That’s great, if you routinely need to test divisibility by 59. Maybe you work for a company that, for some bizarre reason, ships widgets in boxes of 59 and you frequently have to test whether numbers are multiples of 59.

When you want to factor numbers, you’d like to test divisibility by a set of primes at once, using fewer separate algorithms, and taking advantage of work you’ve already done.

John Conway came up with his 150 Method to test for divisibility by a sequence of small primes. This article explains how Conway’s 150 method and a couple variations work. The core idea behind Conway’s 150 Method, his 2000 Method, and analogous methods developed by others is this:

  1. Find a range of integers, near a round number, that contains a lot of distinct prime factors.
  2. Reduce your number modulo the round number, then test for divisibility sequentially, reusing work.

Conway’s 150 Method starts by taking the quotient and remainder by 150. And you’ll never guess what his 2000 Method does. :)

This post will focus on the pattern behind Conway’s method, and similar methods. For examples and practical tips on carrying out the methods, see the paper linked above and a paper I’ll link to below.

The 150 Method

Conway exploited the fact that the numbers 152 through 156 are divisible by a lot of primes: 2, 3, 5, 7, 11, 13, 17, 19, and 31.

He starts his method with 150 rather than 152 because 150 is a round number and easier to work with. We start by taking the quotient and remainder by 150.

Say n = 150q + r. Then n − 152q = r − 2q. If n has three or four digits, q only has one or two digits, and so subtracting q is relatively easy.

Since 19 divides 152, we can test whether n is divisible by 19 by testing whether r − 2q is divisible by 19.

The next step is where sequential testing saves effort. Next we want to subtract off a multiple of 153 to test for divisibility by 17, because 17 divides 153. But we don’t have to start over. We can reuse our work from the previous step.

We want n − 153q = (n − 152q) − q, and we’ve already calculated n − 152q in the previous step, so we only need to subtract q.

The next step is to find n − 154q, and that equals (n − 153q) − q, so again we subtract q from the result of the previous step. We repeat this process, subtracting q each time, and testing for divisibility by a new set of primes each time.

The 2000 method

Conway’s more extensive method exploited the fact that the numbers 1998 through 2021 are divisible by all primes up to 67. So he would start by taking the quotient and remainder by 2000, which is really easy to do.

Say n = 2000q + r. Then we would add (or subtract) q each time.

You could start with r, then test r for divisibility by the factors of 2000, then test rq for divisibility by the factors of 2001, then test r − 2q for divisibility by the factors of 2002, and so on up to testing r − 21q for divisibility by the factors of 2021. Then you’d need to go back and test r + q for divisibility by the factors of 1999 and test r + 2q for divisibility by the factors of 1998.

In principle that’s how Conways 2000 Method works. In practice, he did something more clever.

Most of the prime factors of the numbers 1998 through 2021 are prime factors of 1998 through 2002, so it makes sense to test this smaller range first hoping for early wins. Also, there’s no need to test divisibility by the factors of 1999 because 1999 is prime.

Conway tested rkq for k = −2 through 21, but not sequentially. He would try out the values of k in an order most likely to terminate the factoring process early.

The 10,000 method

This paper gives a much more extensive approach to mental factoring than Conway’s 150 method. The authors, Hilarie Orman and Richard Schroeppel, outline a strategy for factoring any six-digit number. Conway’s rule is more modest, intended for three and four digit numbers.

Orman and Schroeppel suggest a sequence of factoring methods, including more advanced techniques to use after you’ve tried testing for divisibility by small primes. One of the techniques in the paper might be called the 10,000 Method by analogy to Conway’s method, though the authors don’t call it that. They call it “check the m‘s” for reasons that make more sense if you read the paper.

The 10,000 Method is much like the 2000 Method. The numbers 10,001 through 10,019 have a lot of prime factors, and the method tests for divisibility by these factors sequentially, taking advantage of previous work at each step, just as Conway’s methods do. The authors do not backtrack the way Conway did; they test numbers in order. However, they do skip over some numbers, like Conway skipped over 1999.

More Conway-related posts

How Mr. Benjamin squares numbers

This post is a sequel to the post How Mr. Bidder calculated logarithms published a few days ago. As with that post, this post is based on an excerpt from The Great Mental Calculators by Steven B. Smith.

Smith’s book says Arthur Benjamin squares large numbers using the formula

n² = (n + a)(na) + a²

where a is chosen to make the multiplication easier, i.e. to make n + a or na a round number. The method is then applied recursively to compute a², and the process terminates when you get to a square you have memorized. There are nuances to using this method in practice, but that’s the core idea.

The Great Mental Calculators was written in 1983 when Benjamin was still a student. He is now a mathematics professor, working in combinatorics, and is also well known as a mathemagician.

Major system

Smith quotes Benjamin giving an example of how he would square 4273. Along the way he needs to remember 184 as an intermediate result. He says

The way I remember it is by converting 184 to the word ‘dover’ using the phonetic code.

I found this interesting because I had not heard of anyone using the Major system (“the phonetic code”) in real time. This system is commonly used to commit numbers to long-term memory, but you’d need to be very fluent in the system to encode and decode a number in the middle of a calculation.

Maybe a lot of mental calculators use the Major system, or some variation on it, during calculations. Most calculators are not as candid as Benjamin in explaining how they think.

Related posts

How Mr. Bidder calculated logarithms

George Parker Bidder (1806–1878) was a calculating prodigy. One of his feats was mentally calculating logarithms to eight decimal places. This post will explain his approach.

I’ll use “log” when the base of the logarithm doesn’t matter, and add a subscript when it’s necessary to specify the base. Bidder was only concerned with logarithms base 10.

Smooth numbers

If you wanted to calculate logarithms, a fairly obvious strategy would be to memorize the logarithms of small prime numbers. Then you could calculate the logarithm of a large integer by adding the logarithms of its factors. And this was indeed Bidder’s approach. And since he was calculating logarithms base 10, so he could make any number into a integer by shifting the decimal and then subtracting off the number of places he moved the decimal after taking the log of the integer.

Numbers with only small prime factors are called “smooth.” The meaning of “small” depends on context, but we’ll say numbers are smooth if all the prime divisors are less than 100. Bidder knew the logs of all numbers less than 100 and the logs of some larger numbers.

Rough numbers

But what to do with numbers that have a large prime factor? In this case he used the equation

log(a + b) = log(a(1 + b/a)) = log(a) + log(1 + b/a).

So if a number n doesn’t factor into small primes, but it is close to a number a that does factor into small primes, you’re left with the problem of finding log(1 + b/a) where b = na and the fraction b/a is small.

At this point you may be thinking that now you could use the fact that

log(1 + x) ≈ x

for small x. However, Bidder was interested in logarithms base 10, and the equation above is only valid for natural logarithms, logarithms base e. It is true that

loge(1 + x) ≈ x

but

log10(1 + x) ≈ log10(e) x = 0.43429448 x.

Bidder could have used 0.43429448 x as his approximation, but instead he apparently [1] used a similar approximation, namely

log(1 + b/a) ≈ log(1 + 10m) 10m b/a

where b/a is between 10m−1 and 10m. This approximation is valid for logarithms with any base, though Bidder was interested in logs base 10 and had memorized log101.01, log101.001, log101.0001, etc. [2]

Finding nearby smooth numbers

To get eight significant figures, the fraction b/a must be on the order of 0.001 or less. But not every number n whose log Bidder might want to calculate is so close to a smooth number. In that case Bidder might multiply n by a constant k to find a number so that kn is close to a smooth number, take the log of kn, then subtract log k.

Smith says in [1] “For example, to obtain log 877, he would multiply 877 by 13, which gives 11,401, or 600 × 19 + 1.” Then he could calculate

log(877) = log(13*877) −- log(13) = log(11400) + log(1/11400) − log(13)

and use his algorithm for approximating log(1/11400).

I can’t imagine thinking “Hmm. 877 isn’t close enough to a smooth number, but if I multiply it by 13 it will be.” But apparently Bidder thought that way.

Related posts

Here is a simple way to approximate logarithms to a couple significant figures without having to memorize anything.

See also this post on mentally calculating other functions to similar accuracy.

Notes

[1] This equation comes from The Great Mental Calculators by Steven B. Smith. Bidders methods are not entirely known, and Smith prefaces the approximation above by saying “it appears that Bidder’s approximation was …”.

[2]

|-------+-------------|
|     x | log_10(1+x) |
|-------+-------------|
| 10^-2 |  0.00432137 |
| 10^-3 |  0.00043408 |
| 10^-4 |  0.00004342 |
| 10^-5 |  0.00000434 |
| 10^-6 |  0.00000043 |
| 10^-7 |  0.00000004 |
|------+--------------|

Divisibility by base + 1

To test whether a number is divisible by 11, add every other digit together and subtract the rest of the digits. The result is divisible by 11 if and only if the original number is divisible by 11.

For example, start with n = 31425. Add 3, 4, and 5, and subtract 1 and 2. Since 3 + 4 + 5 − 1 − 2 = 9, and 9 is not divisible by 11, neither is 31425.

For another example, take 349041. We have 3 + 9 + 4 = 16, and 4 + 0 + 1 = 5, and 16 − 5 = 11. Since 11 is obviously divisible by 11, so is 349041.

The same trick that works for testing base 10 numbers for divisibility by 11 works for testing base 16 numbers for divisibility by 17. More generally, it works for testing base b numbers for divisibility by b+1.

Let m = b + 1. Then

 b \equiv −1 \pmod m

which implies

\sum_{n=0}^N a_nb^n \equiv \sum_{n=0}^N a_n(-1)^n \pmod m

Here an is the nth digit of a number in base b, numbering the digits from the least significant, counting from 0.

Sometimes a rule for testing divisibility by m will also tell you the remainder when a number is divided by m, but sometimes not. The method presented here will give you the remainder by b + 1, but only if you start adding up digits from the right end. Note in the proof that the digits in even positions (counting from 0) have a positive coefficient and the digits in odd positions have a negative coefficient.

For example, let’s look at 1EDA86hex in hexadecimal (base 16). If we add 6, A, and E, and subtract 8, D, and 1, we get 8, which is the remainder when 1EDA86hex is divided by 11hex (i.e. 17ten). But if we add 1, D, and 8 and subtract E, A, and 8, we get 9.

You can start from either end of a number if you only want to test divisibility, not to compute a remainder. But if you do want the remainder, you might get the wrong result if you start at the wrong end.

Application: Divisibility by 7, 11, and 13

We can apply the technique above to test for divisibility by 1001 in base 1000. And why would we want to do that? Because 1001 = 7 × 11 × 13. Reducing a large number mod 1001 takes the problem of testing for divisibility mod 7, 11, or 13 down to the problem of testing 3-digit numbers.

Base 1000 is just base 10, thinking of triples of ordinary digits as a single base 1000 digit. If we write a number with thousands separators (i.e. commas in some countries, periods in others) then each segment is a base 1000 “digit.”

Example 1

For example, let’s test whether n = 598,203,918 is divisible by 7, 11, or 13.

The alternating (base 1000) digit sum is

598 − 203 + 918 = 1313 = 13 × 101.

The result is clearly divisible by 13, so n is divisible by 13. But since 101 is not divisible by 7 or 11, neither is n.

Example 2

For another example, let n = 314,159,265,358 and find the remainders when n is divided by 7, 11, and 13. We start by reducing n mod 1001.

314159265358 =  −314 + 159 − 265 + 358 = −62 = 939 mod 1001.

Now 939 = 1 = mod 7, so n = 1 mod 7.

Also, 9 + 9 − 3 = 15 = 4 mod 11, and so n = 4 mod 11.

Finally, 939 = 3 mod 13, so n = 3 mod 13.

 

Mentally calculating the day of the week in 2023

Mentally calculating the day of the week will be especially easy in 2023. The five-step process discussed here reduces to three steps in 2023.

One of the steps involves leap years, and 2023 is not a leap year. Another step involves calculating and adding in the “year share,” and the year share for 2023 is zero. So the five steps reduce to these three steps.

  1. Start with a constant corresponding to the month.
  2. Add the day of the month.
  3. Take the remainder by 7.

The constants for each month are as follows.

    | January | 6 | February | 2 | March     | 2 |
    | April   | 5 | May      | 0 | June      | 3 |
    | July    | 5 | August   | 1 | September | 4 |
    | October | 6 | November | 2 | December  | 4 |

You have to come up with your own mnemonics for memorizing this table. As I commented here,

It’s typically much easier to memorize something than to come up with a mnemonic that other people would find acceptable. No matter how natural your mnemonics sound to you, they usually sound like nonsense to anyone else.

Examples

To find the day of the week for July 4, 2023 we start with 5 for July, add 4, and get 9, which leaves a remainder of 2 when divided by 7. Days of the week are numbered starting with Sunday as 0, so 2 corresponds to Tuesday.

Pearl Harbor Day, December 7, will be on a Thursday next year because 4 + 7 leaves a remainder of 4 when divided by 7.

Doomsday

An alternative to the method above is John Conway’s “Doomsday” rule. This rule observes that that every year, the dates 4/4, 6/6, 8/8, 10/10, 12/12, 5/9, 9/5, 7/11, and 11/7 fall on the same day of the week. These dates are easy to memorize because they break down in double pairs of even digits—4/4, 6/6, 8/8, 10/10, and 12/12— and symmetric pairs of odd digits—5/9 and 9/5, 7/11 and 11/7.

For 2023 the Doomsday dates all fall on Tuesday. You can bootstrap your way to calculating other days of the week starting from these landmarks.

You can add “March 0”, i.e. the last day of February, to the list. In 2023 this is February 28 though of course it is sometimes February 29. And when March 0 is February 28, you can add February 0, i.e. January 31, to the list of Doomsday dates.

The Doomsday rule is less work up front than the rule above, but it’s more work in the long run.

Beyond 2023

In general you have to compute the year share in order to find the day of the week of a date, though in 2023 the year share is zero. This post gives multiple ways to compute the year share in your head.

Related posts

A footnote to year share

A couple weeks ago I wrote a post about the year share component of calculating the day of the week. To calculate the day of the week, you need to add the day of the week, a constant for the month, and the year share. Calculating year share is not that hard, but it’s the hardest step to carry out in your head.

The year share of a date y is

⌊5y/4⌋ % 7

where y is the last two digits of a year. There’s no need to multiply by 5, since you could compute

(y + ⌊y/4⌋) % 7

but this still takes some effort if y is large.

The earlier post gave nine different ways to compute the year share, and the easiest in my opinion is method #6:

  1. Round y down to the most recent leap year and remember how much you had to round down. Call that amount r.
  2. Let t be the tens value and u the units value.
  3. Return (2tu/2 + r) % 7.

In symbols,

  1. Let y‘ = 4 ⌊y/4⌋ and r = yy‘.
  2. Let t = ⌊y’/10⌋ and u = y‘ % 10.
  3. Return (2tu/2 + r) % 7.

This method has a longer description but is easier to carry out mentally as the following examples illustrate.

Examples

Let y = 97. Here are the calculations required by the direct method.

  1. y/4⌋ = 24
  2. 97 + 24 = 121
  3. 121 % 7 = 2

Here are the calculations required by the second method.

  1. y‘ = 96 and r = 1.
  2. t = 9 and u = 6.
  3. (2*9 − 3 + 1) % 7 = 2

The former requires adding two 2-digit numbers. The latter requires doubling a single digit number and subtracting another single digit number.

The former requires reducing a 3-digit number mod 7 and the latter requires reducing a 2-digit number mod 7. Furthermore, the 2-digit number is never more than 18.

Proof

To prove that the two methods are equivalent we have to prove

⌊5y/4⌋ ≡ 2tu/2 + r mod 7

which is kinda messy. The way t, u, and r are defined prevent this from being a simple algebraic calculation.

We can verify that

⌊5y/4⌋ ≡ 2tu/2 + r mod 7

for y = 0, 1, 2, … 19 by brute force then prove the rest by induction. We’ll show that if the congruence holds for y then it holds for y + 20.

Suppose you increase y by 20. Then ⌊5y/4⌋ increases by 25. The value of t increases by 2, and the values of u and r remain unchanged, so the right side increases by 4. Since 25 % 7 = 4, the congruence still holds.

Year share

This post will be about psychology as much as math, looking at a number of algorithms for mentally calculating the same function.

The most difficult part of mentally computing days of the week is computing

⌊5y/4⌋ % 7

where y is the last two digits of a year. This quantity is called the year share because it is the year’s contribution to the day-finding algorithm.

The most obvious way to compute this function is to take the whole number part of y/4, add it to y, and take the remainder when dividing by 7. In Python, this would be

    def method0(y): return (y + y//4) % 7

The only reason there’s more to say is that the ease of description is not the same as ease of execution. There are several other methods that some people find easier to use.

Outline

In [1] the author gives several methods for computing the year share. Each of these methods has some advantage over the most direct approach. They generally work with smaller numbers and take advantage of operations that are mentally trivial such as splitting a number into its tens and ones digits.

I’ll describe one of these methods in words, the so-called “odd + 11” method, then implement all the methods in Python. Each method looks more complicated than the direct method if you just glance at the code. But if you mentally execute the code you can see why each method could be easier for a human to carry out.

You can find algebraic proofs of why each method works in [1]. Here I’ll use brute force: the methods only have to work for integer values of y from 0 to 99, so I’ll let Python verify that the methods all produce the same result. This brute force approach uncovered an error in the the paper that I correct in the code below.

Odd + 11 method

Here’s the “odd + 11” method:

  1. If y is odd, add 11 to y.
  2. Divide y by 2.
  3. If y is odd after the step above, add 11.
  4. Set y to the remainder when dividing y by 7.
  5. Return 7 − y.

This method requires adding no more than 11, and it only requires one mental “register.” That is, all operations are done in place. With the direct method, you have to hold y and ⌊y/4⌋ in your head.

Python implementations

Here are Python implementations of 10 methods of computing a value congruent to ⌊5y/4⌋ mod 7. That is, the methods may produce different values, but the values differ by multiples of 7.

Note that the last three methods only require working with single-digit numbers.

Method #6 may be the easiest method to use. YMMV. (Update: See this follow-on post about this method.)

    from math import floor
    
    def method0(y):
        return y + y//4
    
    def method1(y):
        if y % 2 == 1:
            y += 11
        y /= 2
        if y % 2 == 1:
            y += 11
        y %= 7
        return 7 - y
    
    def method2(y):
        parity1 = y % 2
        if parity1:
            y -= 3
        y /= 2
        parity2 = y % 2
        if parity1 != parity2:
            y -= 3
        return -y 
    
    def method3(y):
        t = y % 12
        return y // 12 + t + t//4
    
    def method4(y):
        r = y % 4
        y -= r
        return r - y//2
    
    def method5(y):
        # placeholder to maintain the numbering in the paper
        return method0(y)
    
    def method6(y):
        r = y % 4
        y -= r # i.e. latest leap year
        t = y // 10
        u = y % 10
        return 2*t - u//2 + r
    
    def method7(y):
        t = y // 10
        u = y % 10
        x = (2*t + u) // 4
        x += u
        # The paper says to return 2t - x but it should be the opposite.
        return x - 2*t
    
    def method8(y):
        t = y // 10
        u = y % 10
        p = t % 2
        return (2*t + 10*p + u + (2*p + u)//4) % 7
    
    def method9(y):
        t = y // 10
        u = y % 10    
        return u - t + floor(u/4 - t/2)
    
    # verify all resultss are equal mod 7
    for y in range(100):
        for m in range(10):
            f = eval("method" + str(m))
            assert ((method0(y) - f(y)) % 7 == 0)

Related posts

[1] S. Kamal Abdali. Finding the year’s share in day-of-week calculations. Recreational Mathematics Magazine. Number 6, December 2016.

Mental hash function

A few years ago I wrote about Manual Blum’s proposed method for mentally computing a secure hash function. He proposed using this method as a password manager, using the hash of a web site’s name as the password for the site.

I first wrote about Blum’s method on the Heidelberg Laureate Forum blog, then wrote some footnotes to the post here.

NB: This method is insecure for reasons Rob Shearer describes in the comments.

Algorithm

Blum’s algorithm requires creating and memorizing two things: a random map from letters to digits, and a random permutation of digits.

Let f be a function that maps the set {A, B, C, …, Z} to the set {0, 1, 2, …, 9} created by a random number generator, and let g be a random permutation of {0, 1, 2, …, 9}.

Start with the text you want to hash. Then use f to convert the text to a sequence of digits, replacing each character c with f(c). Label this sequence of digits

a0 a1 a2an.

To create the first digit of your hash value, add the first and last digits of your sequence of digits, take the last digit of the sum, and apply the permutation g to it. In symbols, the first digit of the output, b0, is given by

b0 = g( (a0 + an) % 10 )

where a % 10 is the remainder when a is divided by 10.

For the rest of the digits, add the previous output to the current input, take the last digit, and apply the permutation. That is, for k > 0,

bk = g( (bk−1 + ak) % 10 ).

A few years ago Blum recommended using at least 12 characters.

Python code

Here’s some Python code to implement the method above and make all the details explicit.

    from numpy.random import default_rng
    
    rng = default_rng(20220516)
    
    fdata = rng.integers(10, size=26)
    def f(ch):
        ch = ch.lower()
        return fdata[ord(ch) - ord('a')]
    
    gdata = rng.permutation(10)
    def g(n):
        i = list(gdata).index(n)
        return gdata[(i+1) % 10]
    def hash(text):
        digits = [f(c) for c in text]
        N = len(text)
        out = [0] * N
        out[0] = g((digits[0] + digits[-1]) % 10)
        for i in range(1, N):
            out[i] = g((out[i-1] + digits[i]) % 10)
        return "".join(str(d) for d in out)
    
    print(hash("hello"))

This prints 26752.

Is mental cryptography hopeless?

It’s been eight years since I talked to Manuel Blum. Perhaps he realized years ago that this system is flawed. But I still find his initial question interesting: are there encryption algorithms that humans can execute mentally that cannot be easily broken by computers?

It would be interesting if such an algorithm could at least put up a good fight. Cryptographic algorithms are considered broken if they can be compromised given a few weeks of computing. Could a mental hashing algorithm at least withstand an hour of computer attack?

Mentally calculating the day of the week

In my previous post I mentioned John Conway’s Doomsday rule for calculating the day of the week for any date. This method starts off very simple, but gets more complicated when you actually use it.

This post will present an alternative method that’s easier to use in practice and can be described more succinctly.

Here’s the algorithm.

  1. Take the last two digits of the year and add the number of times 4 divides that number.
  2. Add a constant corresponding to the month.
  3. Add the day of the month.
  4. Subtract 1 in January or February of a leap year.
  5. Take the remainder by 7.

The result is a number that tell you the day of the week.

To be even more succinct, let y be the number formed by the last two digits of the date. Let d be the day of the month. Let L equal 1 if the year is a leap year and the date is in January or February and 0 otherwise. Then the algorithm above can be written as

(y + ⌊y/4⌋ + dL + month constant) % 7.

Here ⌊x⌋ is the floor of x, the greatest integer no greater than x, and x % 7 is the remainder when x is divided by 7.

Update: There are multiple ways to compute the year share, i.e. y + ⌊y/4⌋, that are equivalent mod 7 and easier to carry out mentally than the direct approach.

I’ve deliberately left out a couple details above. What are these month constants, and how does the number at the end give you a day of the week?

Customizing for the 21st century

I learned the method above in the 20th century, and the rule was optimized for the 20th century. You had to subtract 1 for dates in the 21st century.

Also, when I learned the method, it numbered the days of the week with Sunday = 1, Monday = 2, etc. Now I would find it easier to start with Sunday = 0.

Here’s an updated table of month constants that eliminates the need to adjust for dates in the 20th century, and numbers the days of the week from 0.

    | January | 6 | February | 2 | March     | 2 |
    | April   | 5 | May      | 0 | June      | 3 |
    | July    | 5 | August   | 1 | September | 4 |
    | October | 6 | November | 2 | December  | 4 |

If you’d like to number Sunday as 1 rather than 0, add 1 to all the numbers above.

The article I learned this method from came with suggested mnemonics for remembering the month constants. But when you change the constants like I’ve done here, you have to come up with new mnemonics.

Examples

I’m writing this post on Saturday, May 7, 2022. Let’s verify that the method gives the correct day of the week today.

Start with 22, and add 5 because ⌊22/4⌋ = 5. The number for May is 0, so there’s nothing to add for the month. We add 7 because today’s the 7th. This gives us

22 + 5 + 7 = 34

which gives a remainder of 6 mod 7, so this is day 6. Since we started with 0 for Sunday, 6 is Saturday.

Next, let’s do January 15, 2036. We get

36 + 9 + 6 + 15 − 1 = 65

which is 2 mod 7. so January 15 will fall on a Tuesday in 2036. Note that we subtracted 1 because 2036 will be a leap year and our date is in January.

If we want to look at Christmas 2036, we have

36 + 9 + 4 + 25 = 74

which is 4 mod 7, so December 25 will fall on a Thursday in 2036. We didn’t subtract 1 because although 2036 is a leap year, we’re looking at a date after February.

Other centuries

For dates in the 20th century, add 1.

For dates in the 22nd century, subtract 2.

If by some reason you’re reading this article in the 22nd century, make your own table of month constants by subtracting 1 from the numbers in the table above.

Update: See this post for more detail on working with other centuries.

More details

When I was at University of Texas, humanities majors had to take a class we called “math for poets.” The class was a hodgepodge of various topics, and the most popular topic when I taught the class was this method. Here’s a handout I gave the class.

That handout is a little slower paced than this blog post, and goes into some explanation for why the method works. (The method was meant to motivate modular arithmetic, one of the topics on the syllabus, so explaining why the method works was secretly the whole point of teaching it.)

The handout is still valid. You can follow it verbatim, or you can replace the table of month constants with the one above and ignore the 21st century correction step.

Related posts