<?xml version="1.0" encoding="windows-1252"?>
<node id="432598" title="Re^2: OT: Finding Factor Closest To Square Root" created="2005-02-18 20:21:42" updated="2005-08-06 13:15:43">
<type id="11">
note</type>
<author id="145001">
kvale</author>
<data>
<field name="doctext">
You have the right of it. More precisely, take the logarithim. Then the problem becomes finding a sum of log prime factors that is closest to log(N)/2. This problem is reducible to the subset sum problem, which is NP-hard.
&lt;p&gt;
Although exact solutions are exponential, heuristics can sometimes generate good answers with minimal effort. One example of a heuristic that might work well is the greedy heuristic. To fill a box of size log(N)/2, put the largest factor into the box. Then put the next largest factor that still fits in the box and insert it. Keep doing this until no more factors fit. 
&lt;p&gt;
The above will get you the largest factor &lt;= sqrt(N). To get the smallest factor &gt;= sqrt(N), put all the factors in a box, and take them out again largest to smallest, until no more can be taken out.  Finally, comapre the two answers to find the closest.
&lt;p&gt;
Update: fixed a typo.
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-145001"&gt;
&lt;p&gt;
 -Mark
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
432558</field>
<field name="parent_node">
432595</field>
</data>
</node>
