Enigmatic Code

Programming Enigma Puzzles

Enigma 1047: Friday the 13th

From New Scientist #2203, 11th September 1999 [link]

Someone has told George that the 13th of a month is more likely to be a Friday than any other day of the week, but he is not sure whether he should believe it.

This year, 1999, the date Friday the 13th occurs only once, in August. Last year, 1998, it occurred three times, in February, March and November. It is clearly somewhat irregular.

If George choose a random month in a random year on the Gregorian calendar, what is the probability that it will include Friday the 13th? Please give your answer as a fraction in its lowest terms.


3 responses to “Enigma 1047: Friday the 13th

  1. Jim Randell 27 August 2018 at 8:44 am

    The Gregorian Calendar repeats in cycles of length 400 years.

    So we can just count the weekdays that the 13th of each of the 4800 months in a 400 year span occur on.

    This Python program runs in 88ms.

    Run: [ @repl.it ]

    import datetime
    from fractions import Fraction as F
    from enigma import irange, printf
    # count the total number of months, and the weekday of 13th in each
    t = 0
    w = [ 0 ] * 7
    for y in irange(2000, 2399):
      for m in irange(1, 12):
        d = datetime.date(y, m, 13)
        w[d.weekday()] += 1
        t += 1
    for (i, d) in enumerate(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]):
      n = w[i]
      f = F(n, t)
      printf("{d}: {n} / {t} = {f}")

    Solution: The probability that a randomly chosen month has a Friday 13th is 43/300.

    Of the 4800 13th’s of the month, Friday is the most likely day with 688 occurrences, then Sunday and Wednesday with 687 occurrences, then Monday and Tuesday with 685 occurrences, and finally Thursday and Saturday with 684 occurrences.

    So the 13th of the month is slightly more likely to be a Friday than any other given day of the week.

  2. Tessa Fullwood 27 August 2018 at 11:38 am

    Ah yes. This does indicate how ‘random’ is not random when there is an underlying pattern. Then again, my son does a calculation when working out whether to buy a monthly season ticket on the train, rather than a weekly one.

  3. Hugh Casement 27 August 2018 at 11:50 am

    If we take any 28-year period (336 months) between March 1900 and February 2100, then the 13th occurs on a Friday a total of four times in each of the 12 months.  That is a probability of precisely 1 in 7.

    However, in any 400 years three that are multiples of 4 (e.g. 1800, 1900, 2100) are not leap years in the Gregorian calendar.  There are thus four types of century year, with Friday 13th falling in:
    1600, 2000, etc.: October 1700, 2100, etc.: August
    1800, 2200, etc.: June 1900, 2300, etc.: April and July
    400 years = 146097 days, a multiple of 7, so the days of the week repeat,
    and it doesn’t matter which span of 400 we take.

    My frequencies agree with Jim’s.  Total 4800 as expected (though I admit I did not expect the result until I worked it out for myself).

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: