37 lines
936 B
Plaintext
37 lines
936 B
Plaintext
100 cls
|
|
110 max_sieve = 10000000 ' 10^7
|
|
120 dim isprime(max_sieve)
|
|
130 sub carmichael3(p1)
|
|
140 if isprime(p1) = 0 then goto 440
|
|
150 for h3 = 1 to p1-1
|
|
160 t1 = (h3+p1)*(p1-1)
|
|
170 t2 = (-p1*p1) mod h3
|
|
180 if t2 < 0 then t2 = t2+h3
|
|
190 for d = 1 to h3+p1-1
|
|
200 if t1 mod d = 0 and t2 = (d mod h3) then
|
|
210 p2 = 1+int(t1/d)
|
|
220 if isprime(p2) = 0 then goto 270
|
|
230 p3 = 1+int(p1*p2/h3)
|
|
240 if isprime(p3) = 0 or ((p2*p3) mod (p1-1)) <> 1 then goto 270
|
|
250 print format$(p1,"###");" * ";format$(p2,"####");" * ";format$(p3,"#####")
|
|
260 endif
|
|
270 next d
|
|
280 next h3
|
|
290 end sub
|
|
300 'set up sieve
|
|
310 for i = 3 to max_sieve step 2
|
|
320 isprime(i) = 1
|
|
330 next i
|
|
340 isprime(2) = 1
|
|
350 for i = 3 to sqr(max_sieve) step 2
|
|
360 if isprime(i) = 1 then
|
|
370 for j = i*i to max_sieve step i*2
|
|
380 isprime(j) = 0
|
|
390 next j
|
|
400 endif
|
|
410 next i
|
|
420 for i = 2 to 61
|
|
430 carmichael3(i)
|
|
440 next i
|
|
450 end
|