求助!找出给定范围内的佩服数编程
在一个整数的所有真因子(除了本身之外的所有因子)中,若存在一个因子d`,将不是d`的所有因子相加求和,再减掉d`,若等于这个数本身,则称该数为佩服数。例如:12的所有真因子是1、2、3、4、6;12=1+3+4+6-2,因此12是一个佩服数。
下面是书上的编程,求大神完善补充,万分感谢!!!
Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim I As Integer, S As Integer, F() As Integer
Dim A As Integer, B As Integer
A = Text1
B = Text2
For I = A To B
Call Yz(I, F)
If verify(I, F, S) Then
list1.AddItem I & " = " & S
End If
Next I
End Sub
Private Sub Yz(N As Integer, F() As Integer)
Dim I As Integer, K As Integer
For I = 1 To N - 1
if then
ReDim Preserve F(K)
End If
Next I
End Sub
Private Function verify(N As Integer, F() As Integer, St As String) As Boolean
Dim I As Integer, K As Integer, Sum As Integer, J As Integer
For I = 1 To UBound(F)
Sum = 0
For J = 1 To UBound(F)
If J <> 1 Then
St = St & F(J) & "+"
End If
Next J
If N = Sum - F(I) Then
St = Left(St, Len(St) - 1) & "-" & F(I)
Exit Function
End If
Next I
End Function