🔙 All posts

Is my gym locker more likely to be prime?

Where I remember I'm a Mathematician


Planted November 18, 2023

So, before I was developer educator I was a developer, before that I was an educator - specifically a Maths teacher. I worked with 11-18 year olds and tried, sometimes successfully, to make Maths interesting and engaging. I worked hard to help previously Math-phobic and Math-philic(?) students develop a growth mindset.

While teaching, I’d be constantly looking at my life and trying to find examples and uses, patterns and problems I could invite into the classroom.

I do this now as a developer educator but every once in a while my brain starts asking Maths related questions.

That happened while standing in the gym lockers earlier this week.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

I was looking at the lockers and wondering if my locker was more likely to be prime than any other locker. I always go for lockers on the middle row. It’s the right height for me to reach, don’t have to bend down or stretch up.

So, the first thing I had to do was to work out a way to represent the middle row.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Well, that’s a linear sequence. Goes up in 3s so it is some multiple of 3. So, the formula has 3n in it.

3n: 0, 3, 6, 9, …

To make that pattern match my lockers though, I need to add on 2. So, the formula is 3n + 2.

Now, which of the lockers is prime?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

So, for 15 lockers, the middle row is more likely to be prime. But what about for 100 lockers?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

So, the bottom row is the multiples of 3. That means only the first one is prime. Even if the lockers go off to infinity, then the bottom row will stay white.

The of the other two rows then, 3n + 1 and 3n + 2, which is more likely to be prime?

What would be helpful here is to have a table or a graph to see this.

Number of columns3n + 13n + 2
312
30??

I don’t know about you but I don’t want to count those - that’s what computers are for!

Fair warning - my algorithm isn’t super efficient so I’m going to cap it at 10,000. Otherwise, it might crash this page.

Number of columns:

Number of primes in the top row: 1 (probability 10%)

Number of primes in the middle row: 2 (probability 20%)

And here’s a graph of the same data to even bigger numbers. This graph has two lines showing the probability for the top and the middle row.

Graph showing probabilities up to 100,000

So, as the numbers get bigger it is more likely for the middle row to be prime but only just.

I’ve taken this thought experiment as far as I want to right now. I could use formal proof and have fun with that.

For now though, it’s been fun to remember that this part of my brain exists and that I can still use it. I could definitely turn this into a few hours of lessons with my old classes. I don’t teach Maths any more, so you’ll all have to do!

Like what you see?

I send out a (semi) regular newsletter which shares the latest from here and my reading from around the web. Sign up below.

    Your next read?