Jump to content

Twin primes: Difference between revisions

→‎{{header|ALGOL 68}}: Revised task requirements - check for primes less than the specified number
(→‎{{header|ALGOL 68}}: Obvious optimisation and remove unnecessary comments)
(→‎{{header|ALGOL 68}}: Revised task requirements - check for primes less than the specified number)
Line 61:
# note 2 cannot be one of the primes in a twin prime pair, so we start at 3 #
INT twin count := 0;
FOR p FROM 3 BY 2 TO max number - 1 DO IF primes[ p ] AND primes[ p - 2 ] THEN twin count +:= 1 FI OD;
print( ( "twin prime pairs below ", whole( max number, 0 ), ": ", whole( twin count, 0 ), newline ) )
END</lang>
3,048

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.