Python Forum
Calculating Pandigital Numbers
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculating Pandigital Numbers
#4
(Jan-27-2017, 11:43 PM)Ofnuts Wrote:
(Jan-27-2017, 08:43 PM)Flexico Wrote: Inspired by a passage in the book Things to Make and Do in the Fourth Dimension, I threw together an algorithm to find all existing pandigital numbers in a given base. It uses a brute force method utilizing the itertools.permutations function, checking every possible combination of digits. This works well enough for bases up to 11, but beyond that the calculation time goes out of control, as the time function increases with the factorial of one minus the input base. A quick calculation tells me completion of my project (through base 64) would take overĀ 6x10^73 years. Personally, I plan to have moved on to other projects by then.

Does anyone have any more efficient method of testing for pandigital numbers?

The strict definition (all digits used at least once) means that there is an infinite number of pandigital numbers in any given base.

A more restrictive definition (all digits used exactly once, and no zero on left) still produces (n-1)! numbers, but you don't need to "test" them, just generate them, and yes, 63! is a big number...

Yes, I'm using the "every number used exactly once with no zeros" definition. And generating all the possibilities is pretty straightforward (if time-consuming), but how do I know which ones are pandigital?

Oh wait -- I should specify. I'm searching for the ones that follow the rule of the first digit being divisible by 1, the first two digits being divisible by 2, etc. I forgot that's not included in the definition for "pandigital" heh. The only one in base 10 is 381,654,729 for example. That's what I meant by testing.
Reply


Messages In This Thread
Calculating Pandigital Numbers - by Flexico - Jan-27-2017, 08:43 PM
RE: Calculating Pandigital Numbers - by Larz60+ - Jan-27-2017, 09:40 PM
RE: Calculating Pandigital Numbers - by Ofnuts - Jan-27-2017, 11:43 PM
RE: Calculating Pandigital Numbers - by Flexico - Jan-28-2017, 12:59 AM
RE: Calculating Pandigital Numbers - by Ofnuts - Jan-28-2017, 09:42 PM
RE: Calculating Pandigital Numbers - by micseydel - Jan-28-2017, 01:08 AM
RE: Calculating Pandigital Numbers - by Flexico - Jan-28-2017, 02:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,788 May-09-2019, 12:19 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020