Primes whose first and last number is 3: Difference between revisions
Primes whose first and last number is 3 (view source)
Revision as of 17:11, 24 July 2021
, 2 years ago→{{header|ALGOL 68}}: Added stretch goal
(Added Algol 68) |
(→{{header|ALGOL 68}}: Added stretch goal) |
||
Line 14:
{{Trans|ALGOL W}} As with the Go and other samples, generates the candidate sequence.
<lang algol68>BEGIN # find some primes whose first and last digits are 3 #
INT max prime =
# sieve the primes to max prime #
[ 1 : max prime ]BOOL prime;
Line 30:
IF ( p3count +:= 1 ) MOD 12 = 0 THEN print( ( newline ) ) FI
FI # p #;
# find 1, 2, 3 and
p( 3 ); p( 33 ); FOR i FROM 0 BY 10 TO 90 DO p( 303 + i ) OD; FOR i FROM 0 BY 10 TO 990 DO p( 3003 + i ) OD;
#
FOR i FROM 0 BY 10 TO 9 990 DO
FOR i FROM 0 BY 10 TO 99 990 DO IF prime[ 300 003 + i ] THEN p3count +:= 1 FI OD;
print( ( newline, "Found ", whole( p3count, 0 ), " ""3x3"" primes below 1000000", newline ) )
END</lang>
{{out}}
Line 40 ⟶ 42:
3343 3373 3413 3433 3463 3533 3583 3593 3613 3623 3643 3673
3733 3793 3803 3823 3833 3853 3863 3923 3943
Found 2251 "3x3" primes below 1000000
</pre>
|