On the Fediverse, mcc posted :

A machine that beeps once every time the current UTC timestamp is a prime number

which led to a number of responses; one was this from Christian Lawson-Perfect. I’m pretty sure the linked website pre-existed but the date-tracking functionality was newly added. Unfortunately in my browser the beeping doesn’t work.

A few thoughts. First, to explain, the Unix time , which is almost certainly used by your computer or phone, is the number of non-leap seconds since 00:00:00 UTC on Thursday, 1 January 1970. Right now it’s 1699532940, which obviously is not a prime, though 23 seconds earlier, 1699532917 was.

How often would the machine beep? Prime numbers get more and more scarce as you go up, so the beeping rate would constantly decrease. The prime number theorem tells us how fast it decreases. The number of prime numbers less than or equal to $l x$ is approximately $l x/\ln x$. This says that below $l x \approx $ 1,700,000,000 there are about 80,000,000 primes. That’s how many times the machine has beeped, if it was turned on at 00:00:00 on 1 January 1970, an average of once every 21.25 seconds. For the beep rate right now, a little crude calculus approximation says the average time between beeps should be about $l \frac{\epsilon x}{(x+\epsilon x)/\ln(x+\epsilon x)-x/\ln x} \approx 22.3$ seconds (where $l x = 1699532940$ and $l \epsilon$ is some number $l « 1$).

But that’s only an average; it varies. The twin primes conjecture tells us no matter how long the machine runs, there will always be occasions where it beeps twice in two seconds. At the moment I write this, the last time this happened was about 150 seconds ago, at 1699534547 and 1699534549. Likewise about 60 seconds ago there were two beeps 4 seconds apart, the cousin primes 1699534633 and 1699534637, and 475 seconds ago two beeps 6 seconds apart, the sexy primes 1699534223 and 1699534229. This longer duration since the last sexy prime is unusual, because sexy primes occur about twice as often as twin or cousin primes: Below 100,000, for instance, there are 1224 twin prime pairs, 1216 cousin prime pairs, and 2447 sexy prime pairs. This makes sense when you realize if $l p$ is a prime then $l p+2$ and $l p+4$ can be divisible by 3 (one of them must be; there’s a 50% chance of each) but $l p+6$ cannot.

How long can it go between beeps? Bertrand’s postulate says if it beeps at time $l t$, it will definitely beep at least once by time $l 2t$. It’s been almost 54 years since time 0, so it’ll definitely beep at least once in the next 54 years! In fact one can prove the stronger statement (see the above link) it will always beep between $l 3t$ and $l 4t$ — so definitely in the next 18 years.

But if the average time between beeps is 22 seconds, once in 54 or even 18 years would be a hell of a fluctuation. What’s the longest gap that has actually occurred so far? According to this list , at time 1453168141 (Tue 19 Jan 2016 01:49:01 GMT+0000) it beeped and then didn’t beep again for another 292 seconds, nearly 5 minutes. That’s the record. It’ll be broken with a 320 second gap at time 2300942549 (Sun 30 Nov 2042 06:42:29 GMT+0000).

You can construct prime number gaps as large as you like. Consider the number $l 210=2\times 3\times 5\times 7$. Clearly the numbers 210+2, 210+3, 210+4, 210+5, 210+6, 210+7, and 210+8 are divisible by 2, 3, 2, 5, 2, 7, and 2, respectively. More generally, if $l n$# denotes the primorial function, the product of all primes $l \le n$, then for prime $l p$, the numbers $l p$#$l +2, p$#$l +3, p$#$l +4, …, p$#$l +p+1$ are a sequence of $l p$ consecutive composite numbers, though $l p$#$l +1$ and $l p$#$l +p+2$ could be prime. Unfortunately that doesn’t work impressively well. The largest primorial less than the present date is 23# = 223,092,870 (26 Jan 1977), giving a gap of 23 seconds. The next larger primorial 29# = 6,469,693,230 corresponds to a date of 6 Jan 2175, and guarantees only a gap of 29 seconds. In fact the gap is better than that: every number from 6,469,693,190 through 6,469,693,290 is composite, for a gap of 102 seconds. Still, by then the record gap, set in 2106, will already be 354 seconds.

So that’s our beeping machine. By the way, there’ll be a major odometer flip next week, on 14 Nov at 22:13:20 GMT+0000, when the time becomes 1700000000. That’s not prime, obviously, but 1700000009 is. Then the big flip to 2000000000 occurs on 18 May 2033, after which you’ll have to wait 11 seconds for the next beep.