Long primes: Difference between revisions

Added Easylang
m (→‎{{header|RPL}}: formatted code)
(Added Easylang)
Line 660:
Run as: $ crystal run longprimes.cr --release
Time: 0.28927228 secs
 
=={{header|EasyLang}}==
<syntaxhighlight>
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
proc nextprim . .
repeat
prim += 1
until isprim prim = 1
.
.
func 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
.
if period prim = prim - 1
cnt += 1
.
nextprim
until limit > 32000
.
</syntaxhighlight>
 
=={{header|Delphi}}==
2,060

edits