Fun With Math: Calculating Multiplicative Persistence

I mentioned recently that one of my Raspberry Pis is mounted under my desk and tracking the weather, and I've written other times about the other tasks this helpful little assistant handles for me. Today I'd like to discuss yet another thing that little RPi does all day — something I've been pretty excited about for some time.

But first we need to talk about a thing called Multiplicative Persistence.

What is that?

Put very simply, Multiplicative Persistence is a little number trick you can play with integers. Here's how it works:

  1. Take any number
  2. Multiple the digits of the number together
  3. If this number is greater than 9, do it again. Counting the number of times you do the process.
    467 -> 4 x 6 x 7 = 168 (1)
    168 -> 1 x 6 x 8 = 48  (2)
    48  -> 4 x 8     = 32  (3)
    32  -> 3 x 2     = 6   (4)

Result: 467 has a multiplicative persistence of 4

The goal is to find the smallest number with the greatest persistence value. The current largest persistence ever found is 11 and the smallest number is 277777788888899.

What's special about 277777788888899? - Numberphile

You can learn more about Multiplicative Persistence by watching this great video from Numberphile.

What does this have to do with my Raspberry Pi?

I thought it would be fun to write a little script to calculate the known values with the smallest persistences. There are lots of little tricks you can do to speed up your script (so that you don't have to check every single value), and it was a fun little evening project. Then in June I swapped out the script for a new version that used more of the RPi's cores to speed things up a bit.

The script has been running (nearly) continuously since February, and by my estimates it will reach the current largest persistence value by the end of the year.

The script sends me a push notification (via Pushover) whenever it reaches a new persistence value — which is very exciting. I can't wait to get the next notification because that will mean the script has fulfilled its purpose: finding the largest known value.

Next Steps

For no reason whatsoever, after the script reaches the current largest known value I'm going to turn it loose on some truly enormous numbers to see if it can find the next largest value.

Currently it is theorized that 11 is the largest persistence possible (among all base 10 integers), and according to Matt Parker (in the video) mathematicians have already checked every value with less than 233 digits1, but still there are a lot more numbers to check.

Why? Because it's fun.2

Check out the code here →

1 That's a number that looks like this:

2 Because of some local changes to where San Diego's power comes from, all this computation is powered by 100% clean and renewable energy, so I don't feel bad wasting this (admittedly minute) power for nonsense like this.

Filed under: programming, tools, python, software
Other Links: RSS Feed, JSON Feed, Status Page →