0
36-> 6 * 6(未9 * 4)找到單號是彼此最接近
40-> 5 * 8(未10 * 4)
兩個最高的因素35-> 7 * 5 等
我猜是這樣的:
candidate = input.square_root.round_to_nearest_int;
while (true){
test = input/candidate;
if (test.is_integer) return;
else
candidate.decrement;
}
你給出的想法是自然而明確的作品。這不是非常有效,因爲它符合天真的分解分解法。更好的方法可能是首先將數字完全分解(使用比試劃更復雜的東西),然後找到最均衡的方法將這些因素分成兩組。 –
我想我所問的是以平方根開始的起點。但是,它是啓發式和低效率的;我只會輸入最低值爲幾千的值。 – Tel