- #1
Evil Robot
- 6
- 0
A general algorithm works too.
Given: a positive integer n
Return: three positive integers {a,b,c} such that a*b*c=n, the variance of {a,b,c} is minimized, and a>=b>=c.
The return might also be understood as "give the (integer) dimensions of the cubiest cuboid of volume n".
I suspect there is only one possible return for each n, though I suppose I don't have any particular reason to guess that.
While a brute-force style solution is obvious, a mathier solution would be more fun.
Examples (if I'm not mistaken):
f(1) = {1,1,1}
f(2) = {2,1,1}
f(3) = {3,1,1}
f(4) = {2,2,1}
f(5) = {5,1,1}
f(6) = {3,2,1}
f(7) = {7,1,1}
f(8) = {2,2,2}
f(9) = {3,3,1}
f(10) = {5,2,1}
f(11) = {11,1,1}
f(12) = {3,2,2}
f(13) = {13,1,1}
f(14) = {7,2,1}
f(15) = {5,3,1}
f(16) = {4,2,2}
f(17) = {17,1,1}
f(18) = {3,3,2}
f(19) = {19,1,1}
f(20) = {5,2,2}
Above, note especially f(8), f(12), f(16), f(18), and f(20).
Any patterns noticed may be productive. A simple example is that, for a prime number p, f(p)={p,1,1}. Another: for a positive integer n, f(n^3)={n,n,n}.
I'm not sure these results are necessarily unique.
Given: a positive integer n
Return: three positive integers {a,b,c} such that a*b*c=n, the variance of {a,b,c} is minimized, and a>=b>=c.
The return might also be understood as "give the (integer) dimensions of the cubiest cuboid of volume n".
I suspect there is only one possible return for each n, though I suppose I don't have any particular reason to guess that.
While a brute-force style solution is obvious, a mathier solution would be more fun.
Examples (if I'm not mistaken):
f(1) = {1,1,1}
f(2) = {2,1,1}
f(3) = {3,1,1}
f(4) = {2,2,1}
f(5) = {5,1,1}
f(6) = {3,2,1}
f(7) = {7,1,1}
f(8) = {2,2,2}
f(9) = {3,3,1}
f(10) = {5,2,1}
f(11) = {11,1,1}
f(12) = {3,2,2}
f(13) = {13,1,1}
f(14) = {7,2,1}
f(15) = {5,3,1}
f(16) = {4,2,2}
f(17) = {17,1,1}
f(18) = {3,3,2}
f(19) = {19,1,1}
f(20) = {5,2,2}
Above, note especially f(8), f(12), f(16), f(18), and f(20).
Any patterns noticed may be productive. A simple example is that, for a prime number p, f(p)={p,1,1}. Another: for a positive integer n, f(n^3)={n,n,n}.
I'm not sure these results are necessarily unique.