Strange plus numbers: Difference between revisions

→‎{{header|ALGOL 68}}: No need for a sieve - there's only 3 odd numbers < 18 that aren't prime
(Add BASIC)
(→‎{{header|ALGOL 68}}: No need for a sieve - there's only 3 odd numbers < 18 that aren't prime)
Line 90:
=={{header|ALGOL 68}}==
Does not attempt to generalise beyond 3 digit numbers.
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find numbers where the sum of the first 2 digits is prime and also #
# the sum of the second 2 digits is prime #
# considers numbers n where 100 < n < 500 #
PROC small prime = ( INT n )BOOL: n = 2 OR ( ODD n AND n /= 1 AND n /= 9 AND n /= 15 );
PR read "primes.incl.a68" PR
[]BOOLprime = PRIMESIEVE 18; # note: PRIMESIEVE includes 0 in the sieve #
INT s count := 0;
FOR n FROM 101 TO 499 DO
Line 102 ⟶ 100:
INT d2 = v MOD 10; v OVERAB 10;
INT d3 = v;
IF small prime[( d1 + d2 ]) AND small prime[( d2 + d3 ]) THEN
print( ( " ", whole( n, -3 ) ) );
IF ( s count +:= 1 ) MOD 10 = 0 THEN print( ( newline ) ) FI
3,026

edits