小弟又一个小程序不怎么会编,还望大虾们指教!
external f f ( X )=X*X+1
X←X1
X'←f ( X )mod n
p←gcd( X-X' , n )
while p=1
do
comment:在第i此反复中,X=Xi,且 X'=X2i
X←f ( X ) mod n
X'←f ( X' ) mod n
X'←f ( X' ) mod n
p←gcd( X-X' , n )
if p=n
then return("failure")
else return(p)
这个其实就是分解RSA 算法中的 N,小弟刚学VB,不太清楚用VB怎样实现,还盼赐教!
附:gcd(a,b)
Private Sub Command3_Click()
Dim ni%, m1%, m%, n%, r%
n1 = Text1.Text
m1 = Text2.Text
If m1 > n1 Then ' m>n
m = m1: n = n1
Else
m = n1: n = m1
End If
Do
r = m Mod n
If r = 0 Then Exit Do
m = n
n = r
Loop