1406357289, a 0 to 9 pandigital number has a rather interesting sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on.
In the above number we note the following:
• d2d3d4=406 is divisible by 2
• d3d4d5=063 is divisible by 3
• d4d5d6=635 is divisible by 5
• d5d6d7=357 is divisible by 7
• d6d7d8=572 is divisible by 11
• d7d8d9=728 is divisible by 13
• d8d9d10=289 is divisible by 17
List all 0 to 9 pandigital numbers with all those properties.
D4, if solved without software.
I noticed that only nine of the ten digits was being used; the first digit isn't used in the sample. So I decided to try for 19 as well. That never happened, but in order to make things easier to program I started with digits 1-3 instead of 2-4, so that 8-10 could be used for the potential multiple of 19.
The findings were
1063572894 7
1309528674 7
1603572894 7
4063572891 7
4309528671 7
4603572891 7
with the 7 indicating that only the first 7 primes were accommodated.
In terms of what's asked for, putting the first digit last in each case, the six numbers are:
0635728941
3095286741
6035728941
0635728914
3095286714
6035728914
One might disallow the numbers with leading zero. But it does lead to two very nice 9-digit numbers: 635728914 and 635728941 with the given property starting at digit 1 instead of 2.
DefDbl A-Z
Dim crlf$, prm As Variant
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
prm = Array(0, 2, 3, 5, 7, 11, 13, 17, 19)
n$ = "0123456789"
h$ = n
Do
DoEvents
For i = 1 To 8
If Val(Mid(n, i, 3)) Mod prm(i) > 0 Then Exit For
Next
If i > 7 Then
Text1.Text = Text1.Text & n & " " & i - 1 & crlf
End If
permute n
Loop Until n = h
Text1.Text = Text1.Text & crlf & tot & " done"
End Sub
|
Posted by Charlie
on 2016-08-31 11:12:32 |