The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property:
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
Find the sum of all 0 to 9 pandigital numbers with this property.
The numbers and their total:
1406357289
1430952867
1460357289
4106357289
4130952867
4160357289
-----------
16695334890
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
s$ = "0123456789": h$ = s
Do
If Val(Mid(s, 2, 3)) Mod 2 = 0 Then
If Val(Mid(s, 3, 3)) Mod 3 = 0 Then
If Val(Mid(s, 4, 3)) Mod 5 = 0 Then
If Val(Mid(s, 5, 3)) Mod 7 = 0 Then
If Val(Mid(s, 6, 3)) Mod 11 = 0 Then
If Val(Mid(s, 7, 3)) Mod 13 = 0 Then
If Val(Mid(s, 8, 3)) Mod 17 = 0 Then
Text1.Text = Text1.Text & s & crlf
tot = tot + Val(s)
End If
End If
End If
End If
End If
End If
End If
permute s
DoEvents
Loop Until s = h
Text1.Text = Text1.Text & crlf & tot & " done"
End Sub
|
Posted by Charlie
on 2017-07-27 10:30:14 |