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
Not a robot (talk | contribs) (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.
<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 );
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
print( ( " ", whole( n, -3 ) ) );
IF ( s count +:= 1 ) MOD 10 = 0 THEN print( ( newline ) ) FI
|