Numberphile have just done a nice video which combines mathematics and computer programing. The challenge is to choose any number (say 347)

Then we do 3x4x7 = 84

next we do 8×4 = 32

next we do 3×2 = 6.

And when we get to a single digit number then we have finished. It took 3 steps to get from 347 to a single digit number, therefore 347 has a persistence of 3. The challenge is to find a number with as big a persistence as possible. The current world record is 277777788888899 which is the smallest number with a persistence of 11. No numbers with a persistence of greater than 11 have ever been found. In the video Matt writes a Python program to check this, though I tried to make my own version below. It’s not very sophisticated, but it gets the job done (with a small glitch of returning a 0 followed by 1s when it should just return 0s!)

The full code should be available to run here, or download here. If you run the program above in an online Python site like repl.it you can choose any number you like as see what its persistence is.

If you find any number that hasn’t gone to a single digit after 11 rounds, you’ve found a new world record persistence!

To very briefly explain the code used above:

We start by defining “result” as 1. We then have some add any integer number on the screen (let’s use 347). We then do 347 mod 10 (number % 10) which gives 7, and do result (which is 1) multiplied by 7. We then do 347 divided by 10 ignoring remainders (number//10). This gives 34.

We then start the process again. 34 mod 10 = 4. So now we have 1 x 7 x 4. Next we do 34 divided by 10 ignoring remainders which gives 3. Last we do 3 mod 10 = 3. So we have 1 x 7 x 4 x 3. If we carried on the loop we would next have 3/10 = 0 ignoring remainders, therefore our loop would stop.

The program then defines the new starting number as 7x4x3 = 84 and then starts again. So, a nice use of mathematics and computing – see what levels of persistence you can find!

## Leave a comment

Comments feed for this article