48 lines
747 B
Text
48 lines
747 B
Text
fastfunc isprim num .
|
|
if num mod 2 = 0 and num > 2 : return 0
|
|
i = 3
|
|
while i <= sqrt num
|
|
if num mod i = 0 : return 0
|
|
i += 2
|
|
.
|
|
return 1
|
|
.
|
|
prim = 2
|
|
fastproc nextprim .
|
|
repeat
|
|
prim += 1
|
|
until isprim prim = 1
|
|
.
|
|
.
|
|
fastfunc period n .
|
|
r = 1
|
|
repeat
|
|
r = (r * 10) mod n
|
|
p += 1
|
|
until r <= 1
|
|
.
|
|
return p
|
|
.
|
|
#
|
|
print "Long primes up to 500 are:"
|
|
repeat
|
|
nextprim
|
|
until prim > 500
|
|
if period prim = prim - 1
|
|
write prim & " "
|
|
cnt += 1
|
|
.
|
|
.
|
|
print ""
|
|
print ""
|
|
print "The number of long primes up to:"
|
|
limit = 500
|
|
repeat
|
|
if prim > limit
|
|
print limit & " is " & cnt
|
|
limit *= 2
|
|
.
|
|
until limit > 32000
|
|
if period prim = prim - 1 : cnt += 1
|
|
nextprim
|
|
.
|