Dim S As Long
Dim i As Long
Dim j As Long
Dim m As Long
Dim P As Long
Dim Q As Long
Dim R As Long
Dim T As Long
Dim GeShu As Integer
Dim N As Long
N = CInt(txtN)
GeShu = 0
i = 2
Do While (True)
i = i + 1
GeShu = 0
For j = 1 To CInt(i / 2)
For m = i - 1 To CInt(i / 2) Step -1
If i ^ N = m ^ N + j ^ N Then
GeShu = GeShu + 1
If GeShu = 1 Then
P = m
Q = j
Exit For
ElseIf GeShu >= 2 Then
R = m
T = j
S = i
Exit Do
End If
End If
Next
Next
DoEvents
Loop
MsgBox S
End Sub
'add a listbox to form1,sorted=true
'add a commandbutton
'add these codes for the form
Function s(ByVal n As Integer) As Long
List1.Clear
For i = 1 To 20
For j = i To 20
List1.AddItem Format(i ^ n + j ^ n, "000000000")
Next
Next
For i = 0 To List1.ListCount - 1
s = List1.List(i)
If List1.List(i + 1) = List1.List(i) Then
Exit For
End If
Next
List1.Clear
End Function
Private Sub Command1_Click()
Dim p As Long, q As Long, r As Long, t As Long, n As Long, s As Long
p = 1: q = 2: r = 1: t = 2
n = 1
Do Until p ^ n + q ^ n = r ^ n + t ^ n
n = n + 1
Loop
s = p ^ n + q ^ n
Debug.Print s
End Sub