병렬 소수 분해 알고리즘에 대한 접근 방법은 누구나 알 수 있습니까?병렬 기본 분해
알고리즘의 어느 단계에서 스레드로 나누어야하는지 알 수 없습니다. 병렬 분해 방법을 어떻게 생각합니까? 그것은 것 같다
public static void primeFactorization(ArrayList<Integer> factors, int num){
//factors is an array to save the factorization elements
//num is the number to be factorized
int limit = num/2+1;
if(isPrime(num))
factors.add(num);
else{
while(num%2==0){
factors.add(2);
num=num/2;
}
for (int i=3; i<limit; i+=2){
while (isPrime(i) && num%i==0){
factors.add(i);
num = num/i;
}
}
}
}
private static boolean isPrime(int x) {
int top = (int)Math.sqrt(x);
for (int i = 2; i <= top; i++)
if (x % i == 0)
return false;
return true;
}
당신은 병렬 우선 분해가 무엇이고, 무엇을하기로되어 있는지 설명 할 수 있습니까? – Infested
처음에는 소수 인 다수의 수를 확인할 수 있습니다. – Dariusz
1) 더 빨리 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. 2) 코드 블록에 일관되고 논리적 인 들여 쓰기를 사용하십시오. 코드의 들여 쓰기는 사람들이 프로그램 흐름을 이해하도록 돕기위한 것입니다. –