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