The Case of the Prime Suspect

Your PI license to snoop

July 26, 2024 · John Peach

TracerBullett

The investigation opens

A picture of the dame was beginning to emerge. Some said she was polite, happy, balanced, in the prime of her life, and a friend of de Polignac’s. But there was a dark side. She could be amenable to suggestions, especially at the wrong end of a .38, her moods were cyclic, and she was deficient in something, but I didn’t know what. Social skills? Cash to pay off Lenny the mobster? Others called her odious and said she had apocalyptic visions because of how she was raised. In a lineup photo of the usual suspects, she was the shortest. I needed to do a number on her to uncover who she really was.

As I mulled over the case, my eyes drifted to the license plate of a car parked outside my office window. Those four digits… could they hold the key to cracking this case wide open?

That’s when it hit me. This wasn’t just any ordinary case – this was a job for a PI. Not your run-of-the-mill Private Investigator, mind you, but a Prime Investigator. It was time to dig into the mysterious world of number theory, using license plates as my guide.

From the clues could I solve the mystery?

Spade digs in

Look around and you’ll see numbers everywhere and you may even discover some interesting properties. A great source for numbers “in nature” are license plates which occasionally reveal insights into number theory. A well-known property is that of prime numbers which are divisible only by 1 and the number itself. Mathematicians have been studying the properties of primes and have developed many conjectures such as the Goldbach Conjecture mentioned in The Goldfish Conjecture.

Prime numbers are the building blocks of mathematics – numbers divisible only by 1 and themselves. They’re like the lone wolves of the number world, refusing to be broken down any further. And just like in my line of work, these primes have some fascinating characteristics that set them apart from the common numbers.

Let’s start our investigation by looking at some methods for finding divisors of a number. Then, we’ll examine some unusual properties of numbers and use a special tool – a Pari/GP program – to search for four-digit primes that have these properties. By the end of this case, we’ll have uncovered the identity of our mysterious dame – a very special four-digit prime number hiding in plain sight on a license plate.

So grab your magnifying glass and put on your thinking cap. It’s time to solve The Case of the Prime Suspect.

License numbers

License plates often have three letters and four numbers which gives 263×10000=175,760,00026^3 \times 10000 = 175,760,000 possible combinations, plenty enough for any state. Sometimes I try to find the prime factors of the four-digit number on a license plate, and my favorite so far is 48304830 which has prime factors 2,3,5,7,232,3,5,7,23. Since 3×7=213 \times 7 = 21, then we get 21×23×10=483021 \times 23 \times 10 = 4830. If you remember that 222=48422^2 = 484 you can calculate in your head

21×23=(221)×(22+1)=2221=483.21 \times 23 = (22-1) \times (22+1) = 22^2 - 1 = 483.

The last factor 2323 is the concatenation of the first two factors 22 and 33.

How do you find the prime factors of a number? Well, you need to start small and check the first three prime numbers, 2,3, and 52,3, \text{ and } 5. If the number is even then it’s divisible by 22, if the sum of the digits is divisible by 33 then so is the number, and if it ends in 00 or 55, it’s divisible by 55.

Divisibility by 77 is done by dropping trailing zeros, then doubling the last digit and subtracting the answer from the remainder. So, 48304834830 \rightarrow 483, double the 33 and subtract from 4848 to get 4242. Since 4242 is divisible by 7,7, then so is 48304830.

A number is a multiple of 1111 if the sum of the digits in the odd locations minus the sum in the even locations is a multiple of 1111 (including zero). The number 121121 is a multiple of 1111 because 1+12=01 + 1 - 2 = 0, but 48304830 isn’t since 4+38=14 + 3 - 8 = -1.

The trick for 1313 is to multiply the last digit by 44 and add it to the sum of the remaining digits. For 1717 subtract 55 times the last digit from the remaining digits to see if that’s divisible by 1717, and for 1919 add twice the last digit to the remaining number. If the result for any of these is still too large, the process can be repeated.

Make a quick estimate of the square root of the number since the prime divisors don’t need to be any larger than the square root. For 48304830, once you’ve factored out 10=2×510 = 2 \times 5, the square root of 483483 is smaller than 2525, so you won’t need to check anything beyond 2323.

PrimeDivision trick
2Ends in an even number
3Sum of digits is divisible by 3
5Ends in 0 or 5
7Twice the last digit subtracted from the remainder is a multiple of 7
11The sum of the digits in even locations minus the sum of digits in odd locations is a multiple of 11
13Four times the last digit subtracted from the remainder is a multiple of 13
17Five times the last digit subtracted from the remainder is a multiple of 17
19Twice the last digit added to the remainder is a multiple of 19

Sometimes, though, these tricks won’t work because the number you’ve found is prime.

Clues for the PI (Prime Investigator)

I tried all of my sleuthing tricks on a license plate I saw recently, but couldn’t find any divisors. When I got home I checked with Pari/GP which confirmed that the number was prime. Not only that, but it had several other interesting properties, which you can find on the Numbers Aplenty website. The mystery license plate number had these properties:

Can you solve for the mystery number from the clues? Since we know that the number is a four-digit prime (no leading zeros), we know that it’s polite, cyclic and deficient. But, given the other properties, can we point the finger at the suspect? Some of the clues will be much easier to check than others. If we generate a list of prime numbers greater than 1,000 and less than 10,000, it should be fairly easy to find balanced primes.

With a little bit of coding, you can check if a number is happy and odious. It might be a little more difficult to see if it’s apocalyptic, but Pari/GP is capable of calculating 2n2^n for any license plate nn.

One property that might be difficult to check is if a number is amenable. With the other clues available though, maybe we won’t need it.

Narrowing down the list of suspects

With a bit of Pari/GP code the potential list of numbers can be reduced. We know the mystery number is a prime, and In Pari the function primes(n) gives almost what we need. The primes function returns the first nn primes, but what we need are the primes less than a given value.

For a four-digit number, we want primes less than 10,000. The function primepi(n) tells how many primes are less than nn, so by combining the two functions we can get a vector of primes less than nn, p1 = primes(primepi(1e4).

By generating a second vector containing the primes less than 1,000 we can use the setdiff function to get a vector of four digit primes. The function primes_between found in pi_license returns the vector of primes between any two numbers.

There are more than 1,000 four-digit primes, but the list can be significantly shortened by keeping only balanced primes. The next step is to filter out only odious primes which can be done with the Pari functions binary, vecsum and %. The last one is the modulus operator which returns 1 from n % 2 if nn is odd and 0 if nn is even.

The Pari function digits creates a vector of digits from a number, so n=1234n=1234 becomes the vector [1,2,3,4].[1,2,3,4]. Newer versions of Pari/GP permit list comprehension; [x^2 | x <- digits(n)] returns the vector [1,4,9,16][1,4,9,16] and vecsum([x^2 | x <- digits(n)]) gives 1+4+9+16=301+4+9+16 = 30. Sequences always end in one of ten numbers, {0,1,4,16,20,37,42,58,89,145},\{0,1,4,16,20,37,42,58,89,145 \}, and are considered “happy” if the sequence ends in 1.

happy
Figure 1.

Happy integer sequences.

The smallest four-digit apocalyptic number is 10021002,

gp > 2^1002
% = 42860344287450692837937001962400072422456192468221344297750015534814042044997444899727935152627834325103786916702125873007485811427692561743938310298794299215738271099296923941684298420249484567511816728612185899934327765069595070236662175784308251658284785910746168670641719326610497547348822672277504

To find the sequence 666666 in a number, we first need to convert the number to a string, and then use a search function

substr(s,n,m) = strchr(Vecsmall(s)[n..n+m-1]);

to find the substring “666”.

With these detective tools and the clues given above, you should be able to sniff out the right number.

Case closed

I’ll let you run the Pari/GP code pi_license.gp to solve the mystery. You could extend the search by writing functions for some of the other categories found in Numbers Aplenty such as enlightened, frugal, magic, magnanimous, primeval, taxicab, undulating or zygodrome numbers. Taxicab numbers appeared in Haven’s Haven, and are numbers that can be expressed in more than one way as the sum of two cubes.

I didn’t include a function for de Polignac’s condition. Can you write a Pari/GP function to check for this? Would it help narrow down the list of suspects?

If you’re up to a challenge, prove that the search for happy numbers always ends in one of the ten numbers in the set given above. Finding such a proof would be astonishing, brilliant and admirable.

Code for this article

pi_license.gp - Finds a four-digit prime number n such that n is

You may need a text editor such as Notepad++ to write or modify Pari/GP functions.

Software

Image credits