a. What is the smallest number not dividing any 10 digit-pandigital?
b. Same question, but for the non-zero pandigital numbers.
Source: Rodolfo Kurchan
The digits of either kind of pandigital number add up to 45.
45 is divisible by 9, and therefore all pandigital numbers are divisible by both 3 and 9. Some pandigital numbers are divisible by 2, and some of those by 4 and some of those are divisible by 8 (such as those ending in ...128). Those that are divisible by 2 are also divisible by 6 as all are divisible by 3. Any ending in 5 or 0 is divisible by 5.
7 is the first number attempted by the program.
It turns out 100, 200 and 300 are the first three, as each requires the number end with two zeros.
Likewise, when using only digits 1 through 9, all the multiples of 10 fail, including 10 as the first.
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
s$ = "123456789"
h$ = s
Do
v = Val(s)
For i = 7 To 300
q = Int(v / i): r = v - q * i
If r = 0 Then
If dvsr(i) = 0 Then ct = ct + 1
dvsr(i) = 1
End If
Next i
permute s
DoEvents
Loop Until s = h Or ct = 294
If ct = 294 Then
Text1.Text = Text1.Text & "not found" & v
Else
For i = 7 To 300
If dvsr(i) = 0 Then Text1.Text = Text1.Text & Str(i)
Next
Text1.Text = Text1.Text & crlf
End If
|
Posted by Charlie
on 2017-05-02 12:47:47 |