0
私はOKを実行する以下を提出しましたが、私はただ1台のコアマシンしか持っていませんでした。私が持っていればそれ以上のコアに広がっていくというdocumentationsコメントを受け取ります。自動的に。これは、Pythonの3.2b1で実行している私にはOKに見えるこの並行計算は新しいconcurrent.futures libを使用していますか?OKですか?
from concurrent import futures
import math
NUMBERS = [
112272537195293,
112582718962171,
112272537095293,
115280098190773,
115797840077099,
1099726829285419]
def lowest_factor(n):
if n % 2 == 0:
return 2
sqrt_n = int(math.floor(math.sqrt(n)))
for i in range(3, sqrt_n + 1, 2):
if n % i == 0:
return i
return n
def main():
print('For these numbers:\n ' + '\n '.join(str(p) for p in NUMBERS))
with futures.ProcessPoolExecutor() as executor:
low_factor, number = min((l, f) for l, f in zip(executor.map(lowest_factor, NUMBERS), NUMBERS))
print(' The mnimal prime factor is %d of %i' % (low_factor, number))
if __name__ == '__main__':
main()
(r32b1:87064、2010年12月5日、午前19時08分18秒)が、私は他人からの批判を歓迎します。 P.P.私はこのために上記を行いました:http://rosettacode.org/wiki/Parallel_calculations