Jump to content

Circular primes: Difference between revisions

Easylang
m (→‎{{header|Zig}}: update to Zig 0.11.0 - "Allocgate" refactor - casting builtins renaming)
(Easylang)
Line 909:
</pre>
 
 
=={{header|EasyLang}}==
{{trans|AWK}}
<syntaxhighlight lang="easylang">
fastproc isprime n . r .
i = 2
sq = sqrt n
r = 1
while i <= sq and r = 1
if n mod i = 0
r = 0
.
i += 1
.
.
proc cycle n . r .
m = n
p = 1
while m >= 10
p *= 10
m = m div 10
.
r = m + 10 * (n mod p)
.
proc iscircprime p . r .
call isprime p r
if r = 0
break 1
.
call cycle p p2
while p2 <> p
if p2 < p
r = 0
break 2
.
call isprime p2 r
if r = 0
break 2
.
call cycle p2 p2
.
r = 1
.
p = 2
while count < 19
call iscircprime p r
if r = 1
print p
count += 1
.
p += 1
.
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
Line 925 ⟶ 978:
The first 5 repunit primes are R(2) R(19) R(23) R(317) R(1031)
</pre>
 
=={{header|Factor}}==
Unfortunately Factor's miller-rabin test or bignums aren't quite up to the task of finding the next four circular prime repunits in a reasonable time. It takes ~90 seconds to check R(7)-R(1031).
2,054

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.