Jump to content

O'Halloran numbers: Difference between revisions

Added PROMAL
(Added PROMAL)
Line 143:
Even surface areas < 1000 NOT achievable by any regular integer-valued cuboid:
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924
</pre>
 
=={{header|PROMAL}}==
<syntaxhighlight lang="promal">
;;; find O'Halloran numbers - numbers that cannot be the surface area of
;;; a cuboid with integer dimensions
PROGRAM OHalloran
INCLUDE LIBRARY
 
CON WORD maxArea = 1000
WORD count
WORD halfMaxArea
WORD n
WORD l
WORD b
WORD h
WORD lb
WORD lh
WORD bh
WORD sum
BYTE isOHalloran
BEGIN
count = 0
halfMaxArea = maxArea / 2
n = 8
WHILE n <= maxArea
isOHalloran = 1
l = 1
REPEAT
b = 1
lb = l
REPEAT
h = 1
REPEAT
bh = b * h
lh = l * h
sum = 2 * ( lb + ( h * ( b + l ) ) )
IF sum = n
isOHalloran = 0
h = h + 1
UNTIL h > halfMaxArea OR sum > n OR NOT isOHalloran
b = b + 1
lb = l * b
UNTIL b > halfMaxArea OR lb >= n OR NOT isOHalloran
l = l + 1
UNTIL l > halfMaxArea OR NOT isOHalloran
IF isOHalloran
OUTPUT " #W", n
count = count + 1
n = n + 2
END
</syntaxhighlight>
{{out}}
<pre>
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924
</pre>
 
3,048

edits

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