Erdős-primes: Difference between revisions
Content added Content deleted
m (→{{header|C#|CSharp}}: lol, ordinal, not cardinal...) |
(Added solution for Action!) |
||
Line 15: | Line 15: | ||
:* the OEIS entry: [http://oeis.org/A064152 A064152 Erdos primes]. |
:* the OEIS entry: [http://oeis.org/A064152 A064152 Erdos primes]. |
||
<br><br> |
<br><br> |
||
=={{header|Action!}}== |
|||
{{libheader|Action! Sieve of Eratosthenes}} |
|||
<lang Action!>INCLUDE "H6:SIEVE.ACT" |
|||
BYTE Func IsErdosPrime(INT x BYTE ARRAY primes) |
|||
INT k,f |
|||
IF primes(x)=0 THEN |
|||
RETURN (0) |
|||
FI |
|||
k=1 f=1 |
|||
WHILE f<x |
|||
DO |
|||
IF primes(x-f) THEN |
|||
RETURN (0) |
|||
FI |
|||
k==+1 |
|||
f==*k |
|||
OD |
|||
RETURN (1) |
|||
PROC Main() |
|||
DEFINE MAX="2499" |
|||
BYTE ARRAY primes(MAX+1) |
|||
INT i,count=[0] |
|||
Put(125) PutE() ;clear the screen |
|||
Sieve(primes,MAX+1) |
|||
FOR i=2 TO MAX |
|||
DO |
|||
IF IsErdosPrime(i,primes) THEN |
|||
PrintI(i) Put(32) |
|||
count==+1 |
|||
FI |
|||
OD |
|||
PrintF("%E%EThere are %I Erdos primes",count) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Erd%C5%91s-primes.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
2 101 211 367 409 419 461 557 673 709 769 937 967 1009 1201 1259 1709 1831 1889 2141 2221 2309 2351 2411 2437 |
|||
There are 25 Erdos primes |
|||
</pre> |
|||
=={{header|Arturo}}== |
=={{header|Arturo}}== |