我新的蟒蛇,我給兩個數字,在python中查找範圍之間的最大數量的除數?
a = 2
b = 9
a and b
是包容性的範圍即; (2,3,..,9)
。我的期望最高的因數是6 and 8
。
解決方案說明:
4 = 2 * 2(one factor)
6 = 2 * 3(two factor)
8 = 2 * 4(two factor)
9 = 3 * 3(one factor)
因此,需要選擇的因素最多。
如何從上面的邏輯列出python中除數的最大數目?
例:
如果我給的範圍(1,2,..,10)
。那麼它應該給出最高的除數結果是6,8 and 10
。
等..
HTTP:/ /stackoverflow.com/questions/6800193/what-is-the-most-efficient-way-of-finding-all-the-factors-of-a-number-in-python –
...和http://en.wikipedia.org/wiki/Integer_factorization –
請清楚解釋問題。 – thefourtheye