求100到200之间的孪生素数及共有多少对?
若A为素数,而A + 2也是素数,则称A和A +2是一对孪生素数,如3和5是一对孪生素数.
人气:109 ℃ 时间:2020-06-24 01:02:55
解答
Private Sub Command1_Click()
Dim A(100) As Integer
Dim N As Integer
Dim i As Integer, j As Integer, x As Integer
For i = 100 To 200
x = 0
For j = 2 To i - 1
If i Mod j = 0 Then x = 1
Next j
If x = 0 Then
A(N) = i
N = N + 1
End If
Next i
Dim Ncont As Integer
For i = 0 To N - 1
If A(i + 1) - A(i) = 2 Then
Print A(i) & ";" & A(i + 1)
Ncont = Ncont + 1
End If
Next
Print "对数=" & Ncont
End Sub
推荐
猜你喜欢
- In order to encourage the students to study hard,the schoolmaster will give the scholarship to ______got the first prize
- 《醉花阴》中“人比黄花瘦”是千古流传的佳句,以花比人,其中的“瘦”字有什么作用
- 304287读作什么
- 一国两制的基本含义和基本内容?
- 判断1除一个数(0除外)的商,等于这个数的倒数
- 设A=a²+b²-c²,B=-4a²+2b²+3c²,并且A+B+C=0,求C
- 英语“一些;一点”的用法?就是那些短语后加什么 以及理解意思
- 就是关于”快乐假期,轻松阅读“写一篇作文,我不知道该写什么题材,谢