For which bases b is it possible to make a pandigital number in base b that is divisible by 11 in base b?
For example, in base 4: 1023 / 11 = 33. (In base 10 this is 75 / 5 = 15.)
dividend and quotient
in the given bases:
1023 33
10324 434
120435 10545
10234576 730416
102347586 8304326
1024375869 93125079
are such pandigitals in bases 4, 5, 6, 8, 9 and 10.
There are others in these bases, but these were the first found for each of those bases.
It doesn't tell me much. Base 7 is missing. When we go higher than base 10, execution time is too long.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For b = 3 To 30
dvsr = b + 1
low = Int(b ^ (b - 1))
high = Int(b ^ b - 1)
mlt = Int(low / dvsr)
Do
found = 0
prod = dvsr * mlt
inbase$ = base$(prod, b)
If Len(inbase$) = b Then
good = 1
For i = 2 To Len(inbase)
If InStr(inbase, Mid(inbase, i, 1)) < i Then good = 0: Exit For
Next
If good Then
Text1.Text = Text1.Text & inbase & " " & base$(mlt, b) & crlf
found = 1: Exit Do
End If
End If
mlt = mlt + 1
DoEvents
Loop Until prod > high
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function base$(n, b)
v$ = ""
n2 = n
Do
q = Int(n2 / b)
d = n2 - q * b
n2 = q
' d = n2 Mod b
' n2 = n2 \ b
v$ = Mid("0123456789abcdefghijklmnopqrstuvwxyz", d + 1, 1) + v$
Loop Until n2 = 0
base$ = v$
End Function
|
Posted by Charlie
on 2017-07-23 10:39:48 |