29 lines
574 B
Text
29 lines
574 B
Text
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
|
|
|
|
subroutine Wagstaff(num)
|
|
pri = 1
|
|
wcount = 0
|
|
wag = 0
|
|
while wcount < num
|
|
pri += 2
|
|
if isPrime(pri) then
|
|
wag = (2 ^ pri + 1) / 3
|
|
if isPrime(wag) then
|
|
wcount += 1
|
|
print rjust(wcount,2); ": "; rjust(pri,2); " => "; int(wag)
|
|
end if
|
|
end if
|
|
end while
|
|
end subroutine
|
|
|
|
call Wagstaff(9) #BASIC-256 does not allow larger numbers
|
|
end
|