| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

Public Function tuzis(sa As String) As String 'tuzi shulie
Dim A, B, c
A = Val(sa)
B = 1
B1 = 0
b2 = 1
b3 = 0
Do While B <= A
B1 = b2

s1 = s1 & "/" & Trim(b3)

b2 = b3
b3 = MPC1(Trim(B1), Trim(b2))

B = Val(B + 1)

Loop
tuzis = s1

End Function

Private Sub Command1_Click()
Dim A, B, ak()
A = Val(Text1)
B = tuzis(Val(A))
B1 = ksm2(Val(664))
s105 = Split(B, "/")
j1 = UBound(s105)
For k = 1 To j1
n1 = n1 + 1
ReDim Preserve ak(1 To n1)
ak(n1) = s105(n1)
Next
For I = 18 To j1 - 3
A = ak(I)
B = ak(I + 1)
c = ak(I + 2)
x = MPC1(MPC1(MbC(Trim(A), Trim(B)), Trim(c)), Trim(B1))
Y = MPC1(MPC1(MbC(Trim(c), Trim(B)), Trim(A)), Trim(B1))
z = MPC1(MPC1(MbC(Trim(A), Trim(c)), Trim(B)), Trim(B1))
X1 = MPC1(Trim(x), 2)
Y1 = MPC1(Trim(Y), 2)
z1 = MPC1(Trim(z), 2)
Do While Val(js) <= 10
js = Val(js + 1)
If zhengchuqyushu(MCC(Trim(x), 3)) > 1 Or zhengchuqyushu(MCC(Trim(Y), 3)) > 1 Or zhengchuqyushu(MCC(Trim(z), 3)) > 1 Then
If nStr(fenjieyinzi0(Trim(x)), "*") = 0 And InStr(fenjieyinzi0(Trim(X1)), "*") = 0 Then
s = s + 1
s1 = s1 & "/" & s & " /" & x & "/" & X1 & vbCrLf
ElseIf InStr(fenjieyinzi0(Trim(Y)), "*") = 0 And InStr(fenjieyinzi0(Trim(Y1)), "*") = 0 Then
s = s + 1
s1 = s1 & "/" & s & " /" & Y & "/" & Y1 & vbCrLf
ElseIf InStr(fenjieyinzi0(Trim(z)), "*") = 0 And InStr(fenjieyinzi0(Trim(z1)), "*") = 0 Then
s = s + 1
s1 = s1 & "/" & s & " /" & z & "/" & z1 & vbCrLf
Else
s = s
End If
End If
x = MPC1(Trim(x), 2)
Y = MPC1(Trim(Y), 2)
z = MPC1(Trim(z), 2)
X1 = MPC1(Trim(x), 2)
Y1 = MPC1(Trim(Y), 2)
z1 = MPC1(Trim(z), 2)
Loop
Next

If s > 0 Then
Text2 = s1
Else
Text2 = "wu  jie"
End If
End Sub

Private Sub Command2_Click()
Text1 = ""
Text2 = ""

End Sub

Private Function ksm2(sa As String) As String '2的快速幂程序
Dim A, B
A = Val(2): B = sa
If B = 1 Then
ksm2 = A
ElseIf B = 0 Then
ksm2 = 1
Else
a1 = A
Do While B > 1
s = Int(Log(B) / Log(2))
s1 = 0
Do While s1 < s
A = MbC(Trim(A), Trim(A))
s1 = s1 + 1
Loop
a2 = A
B = B - 2 ^ s
A = a1
If s2 > 0 Then
a3 = MbC(Trim(a3), Trim(a2))
Else
a3 = a2
End If
s2 = s2 + 1
Loop
If B = 1 Then
ksm2 = MbC(Trim(a3), Trim(a1))
Else
ksm2 = a3
End If
s3 = Len(ksm2)
ksm2 = ksm2
End If

End Function

/1 /73786976357262128867/73786976357262128869（这就是此法得到的一对孪生素数，前面的1是序号，/号算是间隔号）

/1/1152921504606885899/1152921504606885901
/2/1152921504606888257/1152921504606888259
/3/1152921504606895097/1152921504606895099（这3对孪生素数也是此法得到的）

/1 /76545051729020975577310162521900618820659871603466655644272117978380005723696097587725184512638784526308634214455061267843403507870735540391292521535824647434568377082591826884769598224146796862139607

45771991~45772091之间的素数有8个：（用时1.757813E-02秒）
45772003  45772009  45772033  45772037  45772039  45772057  45772061  45772087

`Select[Range[45771991, 45772091, 2], PrimeQ[#] && PrimeQ[# + 2] &]`

`Select[Range[45771991, 45772091, 2], PrimeQ[#] &]`

{45772003, 45772009, 45772033, 45772037, 45772039, 45772057, 45772061, 45772087}

`Select[2^300 + Range[1, 99999, 2], PrimeQ[#] && PrimeQ[# + 2] &]`

{2037035976334486086268445688409378161051468393665936250636140449354381299763336706183404997,2037035976334486086268445688409378161051468393665936250636140449354381299763336706183418029,2037035976334486086268445688409378161051468393665936250636140449354381299763336706183449367,2037035976334486086268445688409378161051468393665936250636140449354381299763336706183457221,2037035976334486086268445688409378161051468393665936250636140449354381299763336706183472479}

```Select[Range[1, 99999, 2],

PrimeQ[2^800 + #] && PrimeQ[2^800 + # + 2] &]```

2^800 +25051 与 2^800 +25053是一对孪生素数

/1 /24917830127/24917830129
/2 /63497664521/63497664523
/3 /24917830277/24917830279

• 8
• 1/1页
• 1

Powered by Discuz, Processed in 0.045523 second(s), 8 queries.
Copyright©2004-2023, BCCN.NET, All Rights Reserved