27 lines
582 B
Text
27 lines
582 B
Text
print "Wieferich primes less than 5000: "
|
|
for i = 1 to 5000
|
|
if isWeiferich(i) then print i
|
|
next i
|
|
end
|
|
|
|
function isWeiferich(p)
|
|
if not isPrime(p) then return False
|
|
q = 1
|
|
p2 = p ^ 2
|
|
while p > 1
|
|
q = (2 * q) mod p2
|
|
p -= 1
|
|
end while
|
|
if q = 1 then return True else return False
|
|
end function
|
|
|
|
function isPrime(v)
|
|
if v < 2 then return False
|
|
if v mod 2 = 0 then return v = 2
|
|
if v mod 3 = 0 then return v = 3
|
|
d = 5
|
|
while d * d <= v
|
|
if v mod d = 0 then return False else d += 2
|
|
end while
|
|
return True
|
|
end function
|