For each positive integer n, let Mn be the square matrix (nxn) where each diagonal entry is 2018, and every other entry is 1.
Determine the smallest positive integer n (if any) for which the value
of det(Mn) is a perfect square.
DefDbl A-Z
Dim crlf$, tri(100, 100)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
maxsize = 10
For sz = 1 To maxsize
For i = 1 To sz
For j = 1 To sz
If i = j Or i = sz + 1 - j Then
tri(i, j) = 2018
Else
tri(i, j) = 1
End If
Next
Next
Text1.Text = Text1.Text & mform(sz, "##0") & " " & det(sz, tri()) & Str(Sqr(det(sz, tri()))) & crlf
DoEvents
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function det(sz, triangle())
If sz = 2 Then
xx = xx
End If
If sz = 1 Then
det = triangle(1, 1)
Exit Function
End If
ReDim matrix(sz - 1, sz - 1)
tot = 0
For col = 1 To sz
newrow = 0
For r = 2 To sz
newrow = newrow + 1
newcol = 0
For c = 1 To sz
If c <> col Then
newcol = newcol + 1
matrix(newrow, newcol) = triangle(r, c)
End If
Next
Next r
term = triangle(1, col) * det(sz - 1, matrix())
If col Mod 2 = 0 Then term = -term
tot = tot + term
Next col
det = tot
End Function
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
finds
n det square root
1 2018 44.9221548904324
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
7 0 0
8 0 0
9 201964039878876 14211405.2745981
10 0 0
I attribute the anomalous value at n=9 to rounding errors due to the large sizes that the numbers get to at such large matrices.
For n>1, the determinant seems always to be zero, which is a perfect square. So the sought smallest value of n is 2, where the determinant of the matrix is easily seen to be zero as the matrix consists solely of 2018's.
|
Posted by Charlie
on 2018-06-15 07:25:52 |