home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / compiler / ubasic / malm / primen1.ub < prev    next >
Text File  |  1990-08-22  |  674b  |  17 lines

  1.  2300   *Primen1(N,&P(),Leng,&F)
  2.  2310   ' Implements Brillhart, Lehmer, & Selfridge (1975) algorithm.
  3.  2320   ' Returns F=1 for prime, F=0 for no information, & F= -1 for composite.
  4.  2325   ' Assumes n is odd.  Pocklingtons theorem.
  5.  2330   ' 25 May 1990
  6.  2340   local I=0,J,N1,T,Te,Ub=100
  7.  2350   F=0:N1=N-1
  8.  2360   if Leng=0 then return endif
  9.  2370   for J=1 to Leng
  10.  2375   repeat
  11.  2380   inc I:T=N1\P(J):Te=modpow(prm(I),T,N) until or{gcd(Te-1,N)=1,I>Ub}
  12.  2385   if I>Ub then F=0:cancel for:return endif
  13.  2390   Te=modpow(Te,P(J),N)
  14.  2400   if Te<>1 then F=-1:cancel for:return endif
  15.  2410   dec I:next J
  16.  2420   F=1:return ' End of subroutine Primen1.
  17.