Output Distinct Factor Cuboids

JavaScript (V8),  61  60 bytes

Prints the cuboids to STDOUT.

n=>{for(z=n;y=z;z--)for(;(x=n/y/z)<=y;y--)x%1||print(x,y,z)}

Try it online!

Commented

n => {                // n = input
  for(                // outer loop:
    z = n;            //   start with z = n
    y = z;            //   set y to z; stop if we've reached 0
    z--               //   decrement z after each iteration
  )                   //
    for(              //   inner loop:
      ;               //     no initialization code
      (x = n / y / z) //     set x to n / y / z
      <= y;           //     stop if x > y
      y--             //     decrement y after each iteration
    )                 //
      x % 1 ||        //     unless x is not an integer,
      print(x, y, z)  //     print the cuboid (x, y, z)
}                     //

Haskell, 52 bytes

f n=[[a,b,c]|a<-[1..n],b<-[1..a],c<-[1..b],a*b*c==n]

Try it online!

Tuples are in descending order. "3" seems to be a small-enough number that writing out the 3 loops was shorter than anything general I could come up with.


Python 3.8 (pre-release),  83  80 bytes

lambda n:[[i,j,k]for i in(r:=range(n+1))for j in r[i:]for k in r[j:]if i*j*k==n]

Try it online!


...beating a two-loop version by three bytes:

lambda n:[[i,j,n//i//j]for i in(r:=range(1,n+1))for j in r if(i<=j<=n/i/j)>n%(i*j)]