作业帮 > 综合 > 作业

求满足2p*p+p+8=m*m-2m的所有素数p和正整数m

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/10 08:54:48
求满足2p*p+p+8=m*m-2m的所有素数p和正整数m
求满足2p*p+p+8=m*m-2m的所有素数p和正整数m
Private Sub Command1_Click()
For i = 1 To 2000
If Prime(Sum_Y(i)) = True And Prime(i) = False Then Print i
Next
End Sub
'求素数函数
Function Prime(ByVal n As Integer) As Boolean
For i = 2 To Int(Sqr(n))
If n Mod i = 0 Then Prime = False:Exit Function
Next
Prime = True
End Function
'求因子和
Function Sum_Y(ByVal n As Integer) As Integer
Sum_Y = 1
For i = 2 To n
If n Mod i = 0 Then Sum_Y = Sum_Y + i:Sum_Y (n Mod i)
Next
End Function