O'Halloran numbers

From Rosetta Code
Revision as of 22:33, 26 September 2022 by Thundergnat (talk | contribs) (better link text)
O'Halloran numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

For this task, for our purposes, a regular integer cuboid is a 3 dimensional rectangular object, with six faces, where all angles are right angles, where opposite faces of the cuboid are equal, and where each dimension is a positive integer unit length. It will subsequently be referred to simply as a cuboid; but be aware that it references the above definition.

The surface area of a cuboid is two times the length times the width, plus two times the length times the height, plus two times the width times the height. A cuboid will always have an even integer surface area. The minimum surface area a cuboid may have is 6; one where the l, w, and h measurements are all 1.

   2 × ( l × w + w × h + h × l )
   2 × ( 1 × 1 + 1 × 1 + 1 × 1 ) = 6

Different cuboid configurations (may) yield different surface areas, but the surface area is always an integer and is always even.

A cuboid with l = 2, w = 1 h = 1 has a surface area of 10

   2 × ( 2 × 1 + 1 × 1 + 1 × 2 ) = 10

There is no configuration which will yield a surface area of 8.

There are 16 known even integer values below 1000 which can not be a surface area for any integer cuboid. It is conjectured, though not rigorously proved, that no others exist.


Task
  • Find and display the even integer values that can not be the surface area of a regular, integer, rectangular, cuboid, larger than 6 (the minimum) and less than 1000.


See also


Raku

my @Area;

my $threshold = 2000; # a little overboard to make sure we get them all

for 1..$threshold -> $x {
    for 1..$x -> $y {
        last if $x * $y > $threshold;
        for 1..$y -> $z {
           push @Area[($x × $y + $y × $z + $z × $x) × 2], "$x,$y,$z";
           last if $x * $y * $z > $threshold;
        }
    }
}

say "Even integer surface areas NOT achievable by any regular, integer dimensioned cuboid:\n" ~
   @Area[^$threshold].kv.grep( { $^key > 6 and $key %% 2 and !$^value } )»[0];
Output:
Even integer surface areas NOT achievable by any regular, integer dimensioned cuboid:
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924