Jump to content

O'Halloran numbers: Difference between revisions

→‎{{header|ALGOL 68}}: As noted by Phix, once a, b, c has been tried, there is no need to check a, c, b etc.
(Added Go)
(→‎{{header|ALGOL 68}}: As noted by Phix, once a, b, c has been tried, there is no need to check a, c, b etc.)
Line 29:
 
=={{header|ALGOL 68}}==
As noted by the Phix sample, wwe only need to consider one arrangement of each l, b and h values.
<syntaxhighlight lang="algol68">
BEGIN # find O'Halloran numbers - numbers that cannot be the surface area of #
Line 38 ⟶ 39:
BOOL ohalloran := TRUE;
FOR l TO half max area WHILE ohalloran DO
FOR b FROM l TO half max area WHILE INT lb = l * b;
lb < n AND ohalloran
DO
FOR h FROM l TO half max area WHILE INT bh = b * h, lh = l * h;
INT sum = 2 * ( lb + bh + lh );
sum <= n AND ( ohalloran := sum /= n )
AND ( ohalloran := sum /= n )
DO SKIP OD
OD
3,049

edits

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