title: Minimum surface area for a given volume of prism with edges of integer length
body: <p>If I have some <code>int volume</code>, how would I go about writing a method that returns <code>length</code>, <code>width</code>, and <code>height</code> (all ints) so that <code>length*width*height&gt;=volume</code> and <code>2(width*length+height*length+height*width)</code> is as small as possible?</p>
  
  <p>Basically, the smallest surface area (and the values that comprise it) for a given volume of a rectangular prism.</p>
  
  <p>Also, ideally it would be able to set <code>length</code>, <code>width</code>, and/or <code>height</code> and they would remain fixed while solving the problem. For instance, calculate <code>width</code> and <code>height</code> while <code>volume=52</code> and <code>length=3</code>.</p>
  
  <p>EDIT: I wrote this simple brute force to show me the answers I want.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace surface_area_volume_ratio
  {
      class Program
      {
          static void Main(string[] args)
          {
              Console.WriteLine("Volume--\nSurace Area-Ratio : L, W, H");
              Console.ReadLine();
              Console.Clear();
              for (int volume = 1; volume &lt; 200; volume++)
              {
                  double dv=volume;
                  List&lt;double&gt; ratios = new List&lt;double&gt;();
                  List&lt;int&gt; surface = new List&lt;int&gt;();
                  List&lt;int&gt; ls = new List&lt;int&gt;();
                  List&lt;int&gt; ws = new List&lt;int&gt;();
                  List&lt;int&gt; hs = new List&lt;int&gt;();
                  for (int l = 1; l &lt;= volume; l++)
                  {
                      double dl = l;
                      for (int w = 1; w &lt;= volume; w++)
                  {
                      double dw = w;
                      for (int h = 1; h &lt;= volume; h++)
                      {
                          double dh = h;
                          if (l * w * h &gt;= volume)
                          {
                              int s = (2 * (l * w + l * h + w * h));
                              surface.Add(s);
                              ratios.Add(s/dv);
                              ls.Add(l);
                              ws.Add(w);
                              hs.Add(h);
                          }
                      }   
                  }
              }
              double smallest=0;
              if (ratios.Count&gt;0)
                  smallest = ratios.Min();
                  Console.WriteLine(volume+"--");
              for (int i = 0; i &lt; ratios.Count; i++)
              {
                  if (smallest==ratios[i])
                      Console.WriteLine("{0}-{1} : {2}, {3}, {4}",surface[i],ratios[i],ls[i],ws[i],hs[i]);
              }
              Console.ReadLine();
              Console.Clear();
          }
      }
  }
  }
  </code></pre>