Category : BASIC Source Code
Archive   : UBAS830.ZIP
Filename : PRTEST1.UB

 
Output of file : PRTEST1.UB contained in archive : UBAS830.ZIP

˜prtest1 version 2.5
P˜ ADLEMAN-POMERANCE-RUMELY's primality test
x˜ improved by H.W. Lenstra Jr.
 (˜ programmed by Yuji KIDA 1988
©2˜
´<ŸÞñx
çF™" ADLEMAN-POMERANCE-RUMELY's primality test"
P™" Lenstra's version"À™
Z§"Integer ="ÁƒN
Ld³õAdleman(ƒN)Ž™ƒNÁ"is a prime."
mnÀ™ƒNÁ"is a composite."
tx¿
}‚˜
•Œ³õADLEMAN(ƒN)
ë–ºEETGHIJMWNPNQOKPQSWWWKX
2 ºƒEƒINƒM1ƒP1ƒSƒTƒUƒU1ƒVƒV1ƒW…U…W
_ª¤‚IndexñB$)À˜index mod Q with base G
y´¤‚PhiñB$)‚PsiñB$)
Ò¾¤„Tauñ)„Tau1ñ)„Tau2ñ)„Tau_eñ)„Sumñ)„Tau_pñ)À˜16=max of P-1
Ȥ‚Pñ)‚Qñ)‚Gñ)À˜6=no of P -1,27=no of Q -1
2Ò¤‚WKñÂñ)‚EtañÂñ)
;ܘ
Pæõ
PrimeData1
nð‰IÑðŠñÀ›‚PI)ÀŒ
ƒúõ
PrimeData2
«‰IÑðŠñÀ›‚QI)‚GI)ÀŒ
´˜
Èõ
PrimeData1
ê"œñÂñÂñÂñÂñ Âñ
Âñ
ó,˜
6õ
PrimeData2
-@œñÂñÂñÂñÂñ ÂñÂñÂñ
KJœñ+ÂñÂñGÂñÂñÓÂñ
yTœñÂñÂñCÂñÂñKÂñÂñÏÂñÂñ Âñ
¿^œñOÂñÂñƒÂñÂñ#ÂñÂñ[ÂñÂñÂñÂñÓÂñÂñ«
ÂñÂñwÂñ
hœñgÂñÂñïÂñÂñ»ÂñÂñcÂñÂñ/ÂñÂñOÂñÂñó
ÂñÂñC$Âñ
r˜
%|ƒNÑðŽ•(ƒN)
.†˜
<ƒSÑñ
Mš‰NQÑðŠñ
~¤ƒSуSå‚QNQ)ÀƒSïñ҃NŽ”‰À¶
…®Œ
œ¸™À™"Too big."À–À¿
£Â·
Ý́NPÑñÝ(NQÒñ)Ý(NQÒñ)Ý(NQÒñ )Ý(NQÒñ)
æÖ˜
øàƒWруN)
ꍃW‡õDIVISOR?
ô˜
3þ˜** TEST FOR P=2
<˜
\™À™"main test for P="ÁñÁ
nˆõTest4_2
 &HÑñŽSWÑñˆõTest3_2SWсOK
®0MWÑñ
À:‰JÑðŠNQ
ãDQтQJ)ÀGтGJ)
õN™" Q="ÁQÁ
XˆõTest2_2
$bµOKŽ”‰À‡õFAILED
;lSWŽWKсH
QvÀˆõTest5_2
p€ÀµOKŽ”‰À‡õDIVISOR
¯Š‚WKðJ)сWKÀ‚EtaðJ)сETÀWKҁMWŽMWсWK
¶”Œ
Ýž˜* decide max of W and eta(chi)
嗀MWÖñŽ
²À‰JÑðŠNQ
,¼ÀMW҂WKðJ)Ž‚EtaðJ)Ñð—
4ÆÀŒ
LЙÀ™" passed!"
UÚ˜
mä˜** TEST for P>2
vî˜
Šø‰IÑñŠNP
žPтPI)
¿ ™À™"main test for P="ÁPÁ
шõTest4_P
 HÑñŽSWÑñˆõTest3_PSWсOK
*˜
 4MWÑñ
, >‰JÑðŠNQ
O HQтQJ)ÀGтGJ)
w R(QÞñ)çPŽ¨WKÀ¨ETÀ¶
‰ \™" Q="ÁQÁ
› fˆõTest2_P
º pµOKŽ”‰Â‰À‡õFAILED
ñ zSWŽWKсHÀETтIndexƒNçQ)çPÀ¶

„ˆõTest5_P
"
ŽµOKŽ”‰Â‰À‡õFAILED
)
˜·
W
¢‚WKIJ)сWKÀ‚EtaIJ)сET
s
¬WKҁMWŽMWсWK
~
¶ŒJ
¥
À˜* decide max of W and eta(chi)
·
ʍMWÖñŽ
Ê
ÔÀ‰JÑðŠNQ
ä
Þ ÀWKтWKIJ)
 è ÀWKŽMWҁWKŽ‚EtaIJ)Ñð——
 òÀŒJ
7 ü™À™" passed!"
B ŒI
K ˜
a ˜** final test
j $˜
z .ˆõGET_V
š 8™À™"final test using"ÁƒV
¨ BƒWÑñ
Ù LƒTÑñÀ‰IÑðŠNPÀƒTуTå‚PI)ÀŒ
æ VƒT
 `ƒWуWåƒVçƒSÀƒWÑñ‡õALLOK
8 jƒNçƒWÑð‡õ
GETDIVISOR
C t¡ƒT
L ~‘
U ˆ˜
d ’õALLOK
p œ•(ñ)
y ¦˜
‰ °õFAILED
“ º•(ð)
œ Ę
® ÎõDIVISOR?
Ê ØƒWуN‡õALLOK
Þ âõ
GETDIVISOR
è ì•(ð)
ñ ö˜

˜** Subroutines for P=2

˜
=
˜* Check condition 3 for P=2
F
˜
W
(õTest3_2
b
2ºJ
t
<‰JÑðŠNQ
ˆ
FQтQJ)
±
P€ÈƒNQ)ÖñŽ”‰ÀOKÑñÀ¶
¿
ZŒÀOKÑð
Æ
d·
Í
n•
Ö
x˜
ú
‚˜* Check condition 4 for P=2
Œ˜
–õTest4_2
1 …WуNÞñÀHÑÞñ
[ª’…UхWÀ…WхWèñÀ H“£
b´•
k¾˜
È˜* Check condition 2 for P=2
˜Ò˜
©ÜõTest2_2
ÙæƒWсQÀ(QÞñ)çñŽƒWуNރW
ÿðƒUрڃWÂ(ƒNÞñ)èñƒN)
4ú€ÈƒNQ)ÔðŽETÑñÀOKÑ(ƒUуNÞñ)
TÀETÑðÀOKÑ(ƒUÑñ)
[•
d˜
ˆ"˜* Check condition 5 for P=2
‘,˜
¢6õTest5_2
Æ@ƒTрÈÞñQ)åQÀ˜ƒÑ^2
ûJƒTрڃT…UƒN)ÀWKÑñÀOKÑñÀETÑð
TƒTÑñŽ¶
3^ƒTуNÞñŽETÑñÀ¶
<h’
dr WKÀƒWуTÀƒTуTïñçƒN
‡|ƒTуNÞñŽETÑñÀ¶
˜†“ƒTÑñ
¿ƒWрăWƒN)ÀOKÑ(ƒWÑñ)
Æš·
ͤ•
Ö®˜
õ¸˜** Subroutines for P>2
þ˜
"̘* Check condition 3 for P>2
+Ö˜
<àõTest3_P
G꺁J
Yô‰JÑðŠNQ
‚þQтQJ)ÀEÑ(QÞñ)èP
Žµ£Ž
½
À€ÚƒNEQ)ÖñŽ”‰ÀOKÑñÀ¶
ËŒÀOKÑð
Ò&·
Ù0•
â:˜
D˜* Check condition 4 for P>2
0N˜ decompose N^(P%-1)-1 to P%^H%*U
9X˜
JbõTest4_P
rl…WуNï(PÞñ)ÞñÀHÑÞñ
v’…UхWÀ…WхWèPÀ H“£
¤€•
­Š˜
Ñ”˜* Check condition 2 for P>2
Úž˜
¨˜ Calculation of tau(chi)^n/tau(chi^n)
²õTest2_P
$¼ºI
€ÆWÑñÀ‰IÑñŠQÞñÀWсWåGçQÀ‚IndexW)сIçPÀŒÀ˜calc index
ÐˆõTAU_P
ÄڍµSWŽ¢„Tau_pðÁPÞñ)Ñ¢„TauðÁPÞñ)
Íä˜
êîƒEуNèPÀˆõT_E
ø¢„Tau_eðÁPÞñ)Ñ¢„TauðÁPÞñ)
5EуNçPÀˆõJACOBI
D ˆõT_TM
Z˜MAIN OF TEST2
ƒ EтIndexƒNçQ)å(ރN)çP
µ*EсPÞñŽƒWÑÞ(ƒNÞñ)å(PÞñ)
Û4À„TauE)ÖñŽ¨OKÀ¶—
ó>À¡„TauE)À¨ƒW
H‰IÑðŠPÞñÀƒWуW݄TauI)ÀŒ
3ROKÑ(ƒWÑð)
:\·
Af•
Jp˜
nz˜* Check condition 5 for P>2
w„˜
œŽ˜ calculation of tan(chi)^p^u
­˜õTest5_P
½¢ºIJ
鬢„Tau1ðÁPÞñ)Ñ¢„Tau_pðÁPÞñ)
¶„Tauð)ÑñÀ¢„TauñÁPÞñ)Ñð
)À‰IÑðŠ€Â…U)Þñ
Gʍ€ÃI…U)ˆõT_T1
WÔˆõT1_T1
^ތ
mèˆõT_T1
Ÿò˜ check condition 5 by making tau(chi)^p^u
ÃüWKÑñÀˆõW_chiOKŽ¶
Ì ’
ö ¢„Tau1ðÁPÞñ)Ñ¢„TauðÁPÞñ)
! ¢„Tau_eðÁPÞñ)Ñ¢„TauðÁPÞñ)
<$ ‰IÑñŠ€ÂP)Þñ
L.
ˆõT1_T1
j8
€ÃIP)ˆõT_T1
qB Œ
L ˆõT1_T1
V ˆõT_T1
¦`  WKÀˆõW_chi
³j “OK
Ït ETÒðŽOKÑñÀ¶
ç~ ˜ MAIN OF TEST 5
óˆ IÑð
ü’ ¸
œ ƒTфTau_eI)
0¦ €ÄƒTƒN)Ññ‡ñØ
Y° ƒTŽƒWрăTƒN)À¨OKÀ¶
dº  I
mÄ ¹
vÎ ˜
ˆØ ƒTÖñŽ
«â À€ÄƒTÞñƒN)Ññ‡ñ<
—
Ñì ÀƒWрăTÞñƒN)À¨OKÀ¶
èö ÀJсIÝñ
ò
À¸
#

ÀƒTфTau_eJ)À€ÄƒTƒN)Ññ‡ñ<
—
N
ÀƒTŽƒWрăTƒN)À¨OKÀ¶—
Z
À J
d(
À¹
m2

y<
IÑð
‚F

™P
ƒTфTau_eI)
ÃZ
€ÄƒTÝñƒN)ÑñŽOKÑñÀ¶
ùd
ƒTԃNÞñŽƒWрăTÝñƒN)À¨OKÀ¶
n
 I

x

‚

Œ

$–

< 
˜* decide w(chi)
Eª

T´
õW_chi
_¾
ºI
qÈ
ƒTфTauð)
ƒÒ
ƒTÕñŽ
™Ü
ÀƒWуTÀ¨ET
²æ
À‰IÑñŠPÞñ
êð
ÀƒTфTauI)ÀƒTŽƒWуW݃TÀETсI—
òú
ÀŒ
 ÀOKÑ(ƒWÑñ)
( ÀƒTԃNÞñŽ¨OK
D À‰IÑñŠPÞñ
k"
À„TauI)ԃTŽ”‰À¨OKÀ¶—
Š, ÀŒÀOKÑñÀETсPÞñ
‘6 —
˜@ ·
ŸJ •
¨T ˜
Ì^ ˜* calculation of tau(chi)^p
Õh ˜
är õTAU_P
ô| ºIJ
#† ¢‚PsiñÁQÞñ)Ñ¢‚IndexñÁQÞñ)
R ¢‚PhiñÁQÞñ)Ñ¢‚IndexñÁQÞñ)
‚š „Tauð)ÑñÀ¢„TauñÁPÞñ)ÑðÀ˜SET 1
´¤ „Tau1ð)ÑñÀ¢„Tau1ñÁPÞñ)ÑðÀ˜SET 1
Ï® ‰IÑñŠ€ÂP)Þñ
ḠˆõPSI_PSI
 €ÃIP)ˆõPHY_PSI
Ì Œ
Ö ˆõPSI_PSI
*à ˆõT_T1
Tê ¢„Tau1ðÁPÞñ)Ñ¢„TauðÁPÞñ)
jô ¨„Tau1PÞñ)
ƒþ JтPhiQÞñ)
È ‰IÑðŠPÞñÀWÑ(I݁J)çPÀ„TauW)фTau1I)ÀŒ
á ƒWфTauPÞñ)
 ‰IÑðŠPÞñÀ„TauI)Ñ(„TauI)ރW)åQçƒNÀŒ
'& •
00 ˜
N: ˜* calculation of T^E
WD ˜
dN õT_E
tX ºIJ
žb ¢„Tau1ðÁPÞñ)Ñ¢„TauðÁPÞñ)
ªl JÑð
»v €æƒE)Ž
ç€ À€ÃJƒE)ÑðÀˆõT1_T1 JÀ‘
Š À¢„TauðÁPÞñ)Ñ¢„Tau1ðÁPÞñ)
2” ‰IсJÝñŠ€ÂƒE)Þñ
Bž ˆõT1_T1
`¨ €ÃIƒE)ˆõT_T1
g² Œ
n¼ •
wÆ ˜
¦Ð ˜* calculation of tau(chi)^e/tau(chi^e)
¯Ú ˜
¿ä õJACOBI
Ïî ºIJ
úø ¢‚PsiðÁQÞñ)Ñ¢‚IndexðÁQÞñ)
# 
„Tau1ð)ÑñÀ¢„Tau1ñÁPÞñ)Ñð
W
JÑðÀ€ÃJE)ÑðÀˆõPSI_PSI JÀ‘
 
¢„TauðÁPÞñ)Ñ¢„Tau1ðÁPÞñ)
ª
¢‚PhiðÁQÞñ)Ñ¢‚PsiðÁQÞñ)
Ê *
‰IсJÝñŠ€ÂE)Þñ
Ü 4
ˆõPSI_PSI
ý >
€ÃIE)ˆõPHY_PSI
!H

!R

!\

5!f
˜* calculation of T=T*TM
>!p

L!z
õT_TM
\!„
ºIJ
«!Ž
‰JÑðŠPÞñÀ„Tau2J)фTauð)å„Tau_eJ)çƒNÀŒÀ¨„Tau2PÞñ)
Ã!˜
‰IÑñŠPÞñ
Ù!¢
‰JÑðŠPÞñ
)"¬
WÑ(I݁J)çPÀ„Tau2W)фTau2W)݄TauI)å„Tau_eJ)çƒN
0"¶

7"À

Q"Ê
ƒWфTau2PÞñ)
Œ"Ô
‰IÑðŠPÞñÀ„TauI)Ñ(„Tau2I)ރW)çƒNÀŒ
¶"Þ
¢„Tau2ðÁPÞñ)Ñ¢„TauðÁPÞñ)
½"è

Æ"ò

û"ü
˜* calculation of the sum of PSI(A)*PSI(1-A)
#˜
#õPSI_PSI
%#ºIJ
>#$¢„SumðÁPÞñ)Ñð
…#.‰IÑñŠQÞñÀ „Sum(‚PsiI)݂PsiQÝñށI))çP)ÀŒ
©#8˜ calculation of T1=T1*T1*U
ì#B‰IÑðŠ(PÞñ)èñÀ„Tau2ñåI)фTau1I)ïñçƒNÀŒ
L$L‰IÑ(PÝñ)èñŠPÞñÀ„Tau2ñåIށP)фTau1I)ïñçƒNÀŒÀ¨„Tau2PÞñ)
b$V‰IÑðŠPÞñ
$`‰JсIÝñŠPÞñ
Ó$j
WÑ(I݁J)çPÀ„Tau2W)фTau2W)Ýñå„Tau1I)å„Tau1J)çƒN
Ú$tŒ
á$~Œ
%ˆ‰JÑðŠPÞñÀ„Tau1J)фTau2ð)å„SumJ)çƒNÀŒ
6%’‰IÑñŠPÞñ
L%œ‰JÑðŠPÞñ
›%¦
WÑ(I݁J)çPÀ„Tau1W)фTau1W)݄Tau2I)å„SumJ)çƒN
¢%°Œ
©%ºŒ
Ã%ăWфTau1PÞñ)
ÿ%ΉIÑðŠPÞñÀ„Tau1I)Ñ(„Tau1I)ރW)çƒNÀŒ
&ؘ calculation of PSI^2
U&≁IÑðŠQÞñÀ‚PsiI)Ññå‚PsiI)çPÀŒ
\&ì•
e&ö˜
š&˜* calculation of the sum of PHY(A)*PSI(1-A)
£&
˜
´&õPHY_PSI
Ä&ºIJ
Ý&(¢„SumðÁPÞñ)Ñð
$'2‰IÑñŠQÞñÀ „Sum(‚PhiI)݂PsiQÝñށI))çP)ÀŒ
G'<˜ calculation of T=T*T1*SU
•'F‰JÑðŠPÞñÀ„Tau2J)фTauð)å„Tau1J)çƒNÀŒÀ¨„Tau2PÞñ)
­'P‰IÑñŠPÞñ
Ã'Z‰JÑðŠPÞñ
(d
WÑ(I݁J)çPÀ„Tau2W)фTau2W)݄TauI)å„Tau1J)çƒN
(nŒ
(xŒ
\(‚‰JÑðŠPÞñÀ„TauJ)фTau2ð)å„SumJ)çƒNÀŒ
t(Œ‰IÑñŠPÞñ
Š(–‰JÑðŠPÞñ
×( 
WÑ(I݁J)çPÀ„TauW)фTauW)݄Tau2I)å„SumJ)çƒN
Þ(ªŒ
å(´Œ
þ(¾ƒWфTauPÞñ)
8)ȉIÑðŠPÞñÀ„TauI)Ñ(„TauI)ރW)çƒNÀŒ
])Ò˜ calculation of PHY=PHY*PSY
)܉IÑðŠQÞñÀ‚PhiI)Ñ(‚PhiI)݂PsiI))çPÀŒ
¤)æ•
­)ð˜
Î)ú˜* calculation of T=T*T1
×)˜
å)õT_T1
õ)ºIJ
C*"‰JÑðŠPÞñÀ„Tau2J)фTauð)å„Tau1J)çƒNÀŒÀ¨„Tau2PÞñ)
[*,‰IÑñŠPÞñ
q*6‰JÑðŠPÞñ
À*@
WÑ(I݁J)çPÀ„Tau2W)фTau2W)݄TauI)å„Tau1J)çƒN
Ç*JŒ
Î*TŒ
è*^ƒWфTau2PÞñ)
#+h‰IÑðŠPÞñÀ„TauI)Ñ(„Tau2I)ރW)çƒNÀŒ
*+r•
3+|˜
V+†˜* calculation of T1=T1*T1
_+˜
n+šõT1_T1
~+¤ºIJ
Á+®‰IÑðŠ(PÞñ)èñÀ„Tau2ñåI)фTau1I)ïñçƒNÀŒ
!,¸‰IÑ(PÝñ)èñŠPÞñÀ„Tau2ñåIށP)фTau1I)ïñçƒNÀŒÀ¨„Tau2PÞñ)
7,‰IÑðŠPÞñ
T,̉JсIÝñŠPÞñ
¨,Ö
WÑ(I݁J)çPÀ„Tau2W)фTau2W)Ýñå„Tau1I)å„Tau1J)çƒN
¯,àŒ
¶,êŒ
Ð,ôƒWфTau2PÞñ)
-þ‰IÑðŠPÞñÀ„Tau1I)Ñ(„Tau2I)ރW)çƒNÀŒ
-•
-˜
E-˜** subroutine for the final test
N-&˜
q-0˜ * calculation of V mod S
z-:˜
‰-DõGET_V
™-NºIJ
«-X‰JÑðŠNQ
Ë-bƒINтEtaðJ)ÀƒP1Ññ
ß-l‰IÑñŠNP
÷-v
‚WKIJ)Ž
1.€
ÀPтPI)ÀƒU1уP1å€ÛƒP1P)ÀƒV1ÑñރU1
q.Š
ÀƒP1уP1åPÀƒINÑ(ƒINåƒV1݂EtaIJ)åƒU1)çƒP1
x.”Œ
¨.žQтQJ)ÀXрڂGJ)ƒINQ)
¶.¨JŽ
á.²
ÀƒU1уM1å€ÛƒM1Q)ÀƒV1ÑñރU1
/¼
ÀƒM1уM1åQÀƒVÑ(ƒVåƒV1݁XåƒU1)çƒM1
3/ÆÀƒM1сQÀƒVсX
:/Ќ
A/Ú•


  3 Responses to “Category : BASIC Source Code
Archive   : UBAS830.ZIP
Filename : PRTEST1.UB

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/