Primes whose first and last number is 3: Difference between revisions

Content added Content deleted
(add C)
(Added solution for Action!)
Line 10: Line 10:
Find and show only the   ''number''   of these types of primes   that are   '''<   1,000,000'''.
Find and show only the   ''number''   of these types of primes   that are   '''<   1,000,000'''.
<br><br>
<br><br>

=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
<lang Action!>INCLUDE "H6:SIEVE.ACT"

BYTE Func IsSpecialPrime(INT i BYTE ARRAY primes)
BYTE d,first

IF primes(i)=0 THEN
RETURN (0)
FI
first=1
WHILE i#0
DO
d=i MOD 10
IF first THEN
IF d#3 THEN
RETURN (0)
FI
first=0
FI
i==/10
OD
IF d#3 THEN
RETURN (0)
FI
RETURN (1)

PROC Main()
DEFINE MAX="3999"
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 IsSpecialPrime(i,primes) THEN
PrintI(i) Put(32)
count==+1
FI
OD
PrintF("%E%EThere are %I primes",count)
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Primes_whose_first_and_last_number_is_3.png Screenshot from Atari 8-bit computer]
<pre>
3 313 353 373 383 3023 3083 3163 3203 3253 3313 3323 3343 3373 3413 3433 3463
3533 3583 3593 3613 3623 3643 3673 3733 3793 3803 3823 3833 3853 3863 3923 3943

There are 33 primes
</pre>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==