Primes whose first and last number is 3: Difference between revisions
Primes whose first and last number is 3 (view source)
Revision as of 14:03, 29 August 2021
, 2 years ago→{{header|ALGOL 68}}: Use ALGOL 68-primes
m (to 10000) |
(→{{header|ALGOL 68}}: Use ALGOL 68-primes) |
||
Line 13:
=={{header|ALGOL 68}}==
{{Trans|ALGOL W}} With added stretch goal. As with the Go and other samples, generates the candidate sequence.
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find some primes whose first and last digits are 3 #
INT max prime = 1 000 000; # largest number to consider #
# sieve the primes to max prime #
PR read "primes.incl.a68" PR
INT p3count := 0;
# prints n, if it is prime, handles newlines #
Line 30 ⟶ 26:
IF ( p3count +:= 1 ) MOD 12 = 0 THEN print( ( newline ) ) FI
FI # p #;
# find
p( 3 ); p( 33 );
FOR i FROM 0 BY 10 TO 90 DO p( 303 + i ) OD; # 3 digit 3x3 primes #
FOR i FROM 0 BY 10 TO 990 DO p( 3003 + i ) OD; # 4 digit 3x3 primes #
# 5 and 6 digit 3x3 primes #
FOR i FROM 0 BY 10 TO 9 990 DO IF prime[ 30 003 + i ] THEN p3count +:= 1 FI OD;
|