O'Halloran numbers: Difference between revisions

Added JavaScript
(Added Chipmunk Basic, True BASIC and QBasic)
(Added JavaScript)
Line 535:
Values larger than 6 and less than 1_000 which cannot be the surface area of a cuboid:
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924
</pre>
 
=={{header|JavaScript}}==
{{Trans|ALGOL 68}}
<syntaxhighlight lang="javascript">
// find O'Halloran numbers - numbers that cannot be the surface area of
// a cuboid with integer dimensions
'use strict'
const maxArea = 1000
const halfMaxArea = Math.trunc( maxArea / 2 )
let list = ""
for( let n = 8; n <= maxArea; n += 2 )
{
let oHalloran = true
for( let l = 1; l <= halfMaxArea && oHalloran; l ++ )
{
for( let b = l; b <= halfMaxArea; b ++ )
{
const lb = l * b
if( lb >= n || ! oHalloran )break
for( let h = b; h <= halfMaxArea; h ++ )
{
const bh = b * h, lh = l * h
const sum = 2 * ( lb + bh + lh )
oHalloran = sum != n
if( sum > n || ! oHalloran )break;
}
}
}
if( oHalloran )
{
list = list + " " + n
}
}
console.log( list )
</syntaxhighlight>
{{out}}
<pre>
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924
</pre>
 
3,048

edits