Equal prime and composite sums: Difference between revisions

Content added Content deleted
(Added Lua)
(→‎{{header|ALGOL 68}}: Slight simplification)
Line 33: Line 33:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{Trans|XPL0|With a few tweaks}}
{{Trans|XPL0|With a coup[le of tweaks}}
<syntaxhighlight lang="algol68">
<syntaxhighlight lang="algol68">
BEGIN # find n and m where the sums of the first n primes and first m #
BEGIN # find n and m where the sums of the first n primes and first m #
Line 68: Line 68:
m +:= 1
m +:= 1
FI;
FI;
IF sum p /= sum c THEN TRUE # continue the loop #
IF sum p = sum c THEN
ELSE
print( ( whole( sum p, -16 ), whole( n, -10 ), whole( m, -11 ), newline ) );
print( ( whole( sum p, -16 ), whole( n, -10 ), whole( m, -11 ), newline ) );
count +:= 1;
count +:= 1;
IF count >= 8 THEN FALSE # loop stops here #
IF count < 8 THEN
ELSE
WHILE is prime( num c +:= 1 ) DO SKIP OD;
WHILE is prime( num c +:= 1 ) DO SKIP OD;
sum c +:= num c;
sum c +:= num c;
m +:= 1;
m +:= 1
TRUE # continue the loop #
FI
FI
FI
FI;
count < 8
DO SKIP OD
DO SKIP OD
END
END