A basic Java program to find polydivisible numbers, inspired by the "Totally addicted to base" section of Matt Parker's "Things to make and do in the fourth dimension".
According to the source that is Wikipedia...
a polydivisible number is a number with digits abcde... that has the following properties :
-
Its first digit a is not 0.
-
The number formed by its first two digits ab is a multiple of 2.
-
The number formed by its first three digits abc is a multiple of 3.
-
The number formed by its first four digits abcd is a multiple of 4.
-
etc.
For the book's puzzle, the digit zero is not included and we look for solutions in each of the bases.
It seems that this problem is currently not very well documented, and so this program was an attempt to create an open source solution in Java. It loops through each permutation of the digits avaliable in each base, and then checks them. Failures are added to a cache so that they can be instantly dismissed if they reappear as a sequence in another longer permutation.
The biggest challenge is finding solutions in a timely manner. With billions of permutations to check, the more shortcuts that can be found the better. If you've managed to make the program faster, I'll happily accept and PRs.
Things to make and do in the fourth dimension - Matt Parker, 2014, Penguin Publishing
A Conspiracy of digits - Matt Springer, 2014