Problem Description
- Pandigital numbers contain all of the digits 0 through 9 exactly once.
- "Almost pandigital" numbers contain the digits 1 through 9 exactly once.
As an introduction to pandigital numbers,
write a program that finds:
- The smallest pandigital number that is a perfect square.
- A number and it's square which together contain digits 1 through 9 exactly
once (i.e. form an "almost pandigital" number.
Addendum March 30, 2008: Solutions
for three additional sample problems proposed by viewers have been
added:
- Find a pandigital number in which each subset of the first
N digits considered as an integer is exactly divisible by N.
(For example. the number cannot be 1234567890 because even though
"1" is divisible by 1, "12" is divisible by 2, and "123" is
divisible by 3, "1234" is not divisible by 4.)
- Find all equations of the form a x b = c with the property that
a, b, and c are integers and collectively they form an almost
pandigital number, i.e. they contain the digits 1 through 9 exactly
once.
- Find all almost pandigital numbers, using digits 1 thru 9 only
once each, with the property that its square contains each digit 1
thru 9 twice.
Background & Techniques
Both problems depend on generating pandigital
numbers in increasing sequence. Function GetNextPandigital
performs this job for us. It uses the Sawada/SEPA
permutation algorithm introduced in Permutes1.
Some definitions of pandigital specify that it
cannot begin with 0, others do not and I haven't found an
"official" definition. In solving the first problem, I
added a checkbox that lets the user decide if leading zeros count.
Allowing a leading zero, the smallest pandigital is 0123456789;
without a leading zero the smallest is 1023456789.
Running/Exploring the Program
Suggestions for Further Explorations
 |
There are
pairs of pandigital numbers who's products are
palindromes. How many can you find? |
 |
If
abcdefghi is an "almost pandigital" number, find the only
value satisfying a/bc + d/ef +g/hi = 1. |
| Original Date: August 25,2002 |
Modified:
March 30, 2008
|
|